2019年8月12日 星期一

[SQL]INSTALLSHAREDDIR參數指定目錄"c:..."無效。因為此目錄是壓縮目錄或位於壓縮目錄中,請指定一個未壓縮的目錄

因為重灌win10所以重裝資料庫,結果 從2017 裝到2014 再到2012 都是同一個問題
百思不得其解,改了機碼,刪了所有跟MS SQL相關的元還是不行
在快吐血之際……
大陸的網站
https://zhidao.baidu.com/question/1923735875421667707.html
有二個解答
第一個說是目錄被壓縮了
第二個說是目錄有空白

















我信了第二個繞了一個大圈
又看到了同一張圖片…腦中一閃…呀…

[win10]會自動幫忙壓縮檔案…當檔案夾上,有二個相對的藍色鍵頭
就表示win10自動壓縮了?????


只能說win10太雞婆了 沒事幹沒幫忙,造成問題源










2019年8月8日 星期四

[ASP.NET] [目前無法叫用中斷點,未載入這個文件的符號]

參考 http://notesfun.blogspot.com/2016/08/aspnet.html

[ASP.NET] [目前無法叫用中斷點,未載入這個文件的符號]


[目前無法叫用中斷點,未載入這個文件的符號] 我遇到的解法 有以下提示內容




1. 請使用偵錯組建組態,或停用 [啟用 Just My Code] 偵錯選項。

2. 檢查偵錯選項中的 [符號] 設定。




偵錯\選項\停用 [啟用 Just My Code] ,再重新除厝功能就正常囉。

2019年7月28日 星期日

[C#]反組譯DLL

參考https://www.bbsmax.com/A/n2d9Dl1w5D/
參考https://www.cnblogs.com/dudu/archive/2011/05/17/ildasm_ilasm_il.html

 ilasm 源文件.il /output=目标文件.dll /dll

========================= [ dll 成.il ] ======================================
工具 C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\ildasm.exe

傾印成.il後
移除不要的部份 ex:強名稱



=============================[ .il => dll]==================================
C:\Windows\Microsoft.NET\Framework\v4.0.30319>ILASM  D:\temp\dll\L\SmoothEnterprise.Web.Control.Enterprise.il /OUTPUT=D:
\temp\dll\L\SmoothEnterprise.Web.Control.Enterprise.dll


ilasm D:\temp\dll\L\SmoothEnterprise.Web.Control.Enterprise.il /output=D:\temp\dll\L\SmoothEnterprise.Web.Control.Enterprise.dll /dll  /RESOURCE=D:\temp\dll\L\SmoothEnterprise.Web.Control.Enterprise.res

2019年5月2日 星期四

[FileUpload] UpdatePanel+ FileUpload 在PostBack 後會失效

FileUpload 在上傳檔案後 在PostBack 後 就失效了,無法再上傳了
這是FileUpload 的缺點,在 https://dotblogs.com.tw/stanley14/2016/08/10/173019的文章中
發現 重新註冊trigger 可以解決 這個問題,

protected void Page_Load(object sender, EventArgs e) { Master.UpdatePanel1.Triggers.Add(new PostBackTrigger { ControlID = Button1.UniqueID }); Page.Form.Attributes.Add("enctype", "multipart/form-data"); ScriptManager.GetCurrent(Page).RegisterPostBackControl(Button1); }


//我在網頁上多個 UpdatePanel 的寫法

  foreach (Control ctl in Page.Master.FindControl("ContentPlaceHolder1").Controls)
        {
            //Utility.log(1, ctl.ID.ToString());
            if (ctl.GetType().Name == "UpdatePanel")
            {
                UpdatePanel p = (UpdatePanel)ctl;

                string name = p.ID.Replace("panel_", "btn_");
                string type = p.ID.Replace("panel_", "");

                Button btn = (Button)p.FindControl(name);

                btn.Text = getStr("upload_file");

                //因為fileUpload 在postback 後,上傳功能會鎖住 所以必需要重新註冊
                //https://dotblogs.com.tw/stanley14/2016/08/10/173019 參考這篇 重新註冊 trigger
                PostBackTrigger trigger = new PostBackTrigger();
                trigger.ControlID = btn.ID;
                p.Triggers.Add(trigger);
                ScriptManager.GetCurrent(Page).RegisterPostBackControl(btn);
//Page.Form.Attributes.Add("enctype", "multipart/form-data");經測試,這行其實不需要
                if (_attach.Rows.Count > 0)
                {
                    attach_List(type);
                }
            }
        }



2019年4月24日 星期三

[C#] Dispose 資源釋放

namespace Yield
{
     public class TsRun : IDisposable
    {
        private bool alreadydisposed = false;
        private System.Threading.Timer ThreadTimer;
         public TsRun()
        {
            if (ThreadTimer == null)
            {
                ThreadTimer = new System.Threading.Timer(new System.Threading.TimerCallback(RFID_Read), null, 0, 1000);
            }
        }
        private void Stop()
        {
            if (ThreadTimer != null)
            {
                alreadydisposed = true;
                ThreadTimer.Dispose();
                ThreadTimer = null;
            }
        }
        #region dispose
        ~TsRun()
        {
            Dispose(false);
        }
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!alreadydisposed)
            {
                return;
            }
            if (disposing)
            {
                //释放托管资源
                //託管資源:由CLR管理分配和釋放的資源,即由CLR裡new出來的物件;
                Stop();
            }
            //释放非托管资源
            alreadydisposed = true;
        }
        #endregion dispose
    }
}
參考: Effective C# — .NET資源管理

2019年2月14日 星期四

[asp.net]無效的回傳或回呼引數。已在組態中使用 ....

參考 KB-About Event Validation of ASP.NET 2.0

因在asp.net 2.0中使用ajax來更新網頁元件中的項目(DropDownList 的清單)
引發enableEventValidation驗證,

在黑大文中所述,因為網頁元件的資料非該網頁原生,導致資安疑慮,而讓asp.net中止網頁執行。

我因為要做多階式動態表單,DropDownList的資料由ajax更新,而引enableEventValidation驗證,為了解決這個問題 ,我將DropDownList 所屬的所有資料,在第一次進入網頁中,就載入網頁再使用ajax 去更新DropDownList 的資料,即可。

2019年1月8日 星期二

[C#]數字轉字串,比對判斷不正確的處理方式

因為oracle存檔數字格式為0.00000
而user 在網頁上要看到的格式為 1,234.123456
要比對db與網頁上的資料不符者,
產出xml 依xml 資料回存被異動的資料至oracle ,但資料格式不相同

要處理
1.oracle 產出的數字 0.00000 顯示至網頁 textbox  為 1,234.25
2.網頁顯示 1,234.56 要回存DB為 1234.100000
3.輸出xml 為1234.100000

本來以是字串處理,但是db輸出的字串與 textbox 的字串比對,
顯示上都是一樣的,但C#判別為不相符。

後來改以數字處理比對即可
將存入的字數以  Response.Write (String.Format("{0:00000.0000}", 123.45)); 處理

數字轉字串之格式可參考 http://goodlucky.pixnet.net/blog/post/30233497-%5Bc%23%5D-string.format%E8%BC%B8%E5%87%BA%E6%A0%BC%E5%BC%8F

因為C#沒有IsNumeric 故使用正達式 來處理

/// <summary>
    /// 是否是有小數(不論正負)
    /// </summary>
    /// <param name="examine"></param>
    /// <returns></returns>
    public static bool IsFloat(string examine)
    {
        bool chk = false;
        if (!string.IsNullOrEmpty(examine))
        {
            Regex NumberPattern = new Regex(@"^(-[0-9]*|[0-9]*)$|^(-[0-9]*|[0-9]*)(\.{1}\d*)$");
            chk = NumberPattern.IsMatch(examine);
        }
        return chk;
    }

    public static bool IsInteger(string examine)
    {
        Regex NumberPattern = new Regex(@"^(-[0-9]*|[0-9]*)$");
        return NumberPattern.IsMatch(examine);
    }

    public static bool getRegex(string examine, string regex)
    {

        Regex NumberPattern = new Regex(regex);
        return NumberPattern.IsMatch(examine);
    }