開發工具:VS2010
DB Driver:Oracle Client 11gR2 64bit
OS:Win7 64bit
.NET Framework 4.0
使用Oracle Provider發生:System.InvalidOperationException 嘗試載入 Oracle 用戶端程式庫時傳出 BadImageFormatException。當與具有 32 位元的 Oracle 用戶端元件執行 64 位元模式安裝時,會出現此問題。
在網路上許多文章是說只要將VS的組態設定成X86即可。但是此方法對我的狀況沒有改善
解決方法:
1.將Oracle Client移除
2.OS重新開機
3.重裝Oracle Client 64bit(依OS的版本)
4.解決
2013年9月13日 星期五
2013年5月22日 星期三
[系統]製作USB開機碟+NoName XPE
一,需事先準備下面幾項工具
注意:USB隨身碟在第一步驟時會作格式化,所以裡面原本有檔案的話會被清除。



1.HP USB Disk Storage Format Tool (製作開機區)。
2.Grub4dos Installer (設定開機檔)。
3.grldr 及 grub.exe 二個檔案 (Grub4Dos內的二個檔案) (下載)。
4.NoName XPE (自製XP精簡版 ISO檔)。
5.準備一支USB 2.0/3.0 1G 以上的隨身碟。二,開始製作
注意:USB隨身碟在第一步驟時會作格式化,所以裡面原本有檔案的話會被清除。
1.先將USB插入。
2.執行HP USB Disk Storage Format Tool 程式。
3.選擇USB裝置,快速格式,建立一個DOS開機作業磁碟,DOS系統檔案位置。
4.開始(Start)。
5.執行Grub4dos Installer 工具設定MBR。
6.Disk<-選擇你USB裝置(如果抓不到請用管理員權限來執行此程式)。
7.Options<-勾選No backup MBR ,Don’t search floppy ,Disable PrevMBR。
8.Install。
9.將下載回來的XPE ISO解壓縮,或者用酒精先掛載起來。
10.將XPE ISO內的檔案複製到USB隨身碟:
- A.複製整個XPE ISO內的檔案到USB隨身碟。
- B.將RXPE資料夾內的RXPE.COM及SETUPLDR.BIN檔案複製到USB隨身碟根目錄下。
- C.將USB隨身碟下的SETUPLDR.BIN檔案更名為NTLDR。
11.USB隨身碟根目錄下會有這些資料夾及檔案。
12.恭喜你完成了,快找台電腦來測試吧!
2013年5月20日 星期一
[VB.NET]跨執行緒作業無效-跨執行續操作UI
一,依WindowsForm來說,介面上有二個Button,有一支執行續需要設定這二個Button的Enabled。
如果直接設定會出現跨執行緒作業無效的錯誤訊息。
所以我們可以使用委派來處理跨執行續的問題。
Private Delegate Sub MyButtonCallBack(ByVal StartValue As Boolean, ByVal StopValue As Boolean)
Private Sub SetButtonEnabled(ByVal StartValue As Boolean, ByVal StopValue As Boolean)
'判斷是否由執行緒以外的執行緒呼叫,若不是則直接設定Button
If Me.InvokeRequired Then
'實作委派方法
Dim MyButton As New MyButtonCallBack(AddressOf SetButtonEnabled)
'執行委派
Me.Invoke(MyButton, StartValue, StopValue)
Else
Me.btnStart.Enabled = StartValue
Me.btnStop.Enabled = StopValue
End If
End Sub
2013年5月14日 星期二
[VB.NET]Custom Contol自訂控制項事件
一,客製一個控制項是繼承Button,增加一個按下滑鼠右鍵Click事件,事件名稱:RightClick
自訂控制項
Public Class SuperButton Inherits Button Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) '請在此處加入您自訂的繪製程式碼 End Sub '自訂一個新的事件RightClick Dim _handlers As New List(Of EventHandler) Public Custom Event RightClick As EventHandler AddHandler(value As EventHandler) _handlers.Add(value) End AddHandler RemoveHandler(value As EventHandler) If _handlers.Contains(value) Then _handlers.Remove(value) End If End RemoveHandler RaiseEvent(sender As Object, e As System.EventArgs) For Each handler As EventHandler In _handlers Try handler.Invoke(sender, e) Catch ex As Exception Debug.WriteLine(ex.ToString()) End Try Next End RaiseEvent End Event '監聽滑鼠事件 Protected Overrides Sub OnMouseDown(mevent As System.Windows.Forms.MouseEventArgs) MyBase.OnMouseDown(mevent) '當滑鼠被按下右鍵時則回應自訂事件 If mevent.Button = Windows.Forms.MouseButtons.Right Then RaiseEvent RightClick(Me, mevent) End If End Sub End Class
[Web Service]Console Mode 基礎連接已關閉: 無法為SSL/TLS 安全通道 忽略認證
Imports System.Net
Imports System.Net.Security
Imports System.Security.Cryptography.X509Certificates
Module Module1
Sub Main()
Dim oWebCilent As New TEST.ReceiveClient
Dim oResponse As TEST.ServiceResponse
'委派認證回呼
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateServerCertificate)
Try
'........
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
'忽略認證直接回傳True
Public Function ValidateServerCertificate(ByVal sender As [Object], ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
Return True
End Function
End Module
2013年4月16日 星期二
[VB.NET]使用System.Configuration命名空間處理自訂的應用程式組態檔Config
在WinForm組態檔來說,較常使用的app.config,當專案建置後app.config會被編譯成(xxxx.exe.config)。
但是這樣只有此專案能使用這個app.config而已,如果當有多個專案要共用的話,其他專案也都加入此app.config,才能讀取得到。
當然有很多種方法可以解決這個問題,這裡只提供其中一種方法當作範例。
1.先在專案中加入一個自訂的應用程式組態檔 Sample.config
3.讀取Sample.config
但是這樣只有此專案能使用這個app.config而已,如果當有多個專案要共用的話,其他專案也都加入此app.config,才能讀取得到。
當然有很多種方法可以解決這個問題,這裡只提供其中一種方法當作範例。
1.先在專案中加入一個自訂的應用程式組態檔 Sample.config
2.加入參考System.Configuration命名空間
3.讀取Sample.config
Imports System.Configuration Module Module1 Sub Main() Dim configFileMap As ExeConfigurationFileMap Dim config As Configuration Dim configKeyValue As KeyValueConfigurationElement Try configFileMap = New ExeConfigurationFileMap configFileMap.ExeConfigFilename = "Sample.config" config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None) configKeyValue = config.AppSettings.Settings("Test") If configKeyValue Is Nothing Then Console.WriteLine("指定Key錯誤。") End If Console.WriteLine("Test=" + configKeyValue.Value) Console.ReadKey() Catch ex As Exception Console.WriteLine(ex.Message) Console.ReadKey() Finally configFileMap = Nothing config = Nothing configKeyValue = Nothing End Try End Sub End Module
2012年8月1日 星期三
[VB.NET]程式中使用SQL字串IN參數化設定
一,寫程式時在使用SQL字串時,WHERE條件的參數,我們需要參數化,以防止SQL Injection發生,
ADO.Net 有提供相關參數化設定,但是當我們遇到使用IN子句時,要如何使用參數化?
Dim parameString As String = "123,456,789"
Dim parameArray() As String
Dim temp As String
comm.CommandText = "SELECT * FROM TEST WHERE ID IN (@ID)"
parameArray = parameString.Split(",")
For i = 0 To parameArray.Length - 1
temp &= String.Format("@ID{0},", i)
Next
comm.CommandText = comm.CommandText.Replace("@ID", temp.Substring(0, temp.Length - 1))
For j = 0 To parameArray.Length - 1
comm.Parameters.Add(String.Format("@ID{0}", j), SqlDbType.VarChar).Value = parameArray(j)
Next
comm.ExecuteReader()
訂閱:
文章 (Atom)