我在VB.Net中創建了一個用於Visual Foxpro應用程序的DLL。最近,我添加了一些功能來幫助清理數據並清除用戶控件的輸入並重新構建項目。我目前使用Regasm來註冊DLL,這似乎工作正常。但是,當我註冊的DLL,新功能不顯示,使它看起來像一個仍在使用舊的,以前註冊的DLL。有沒有事情我做得不對? 下面是代碼的摘錄。添加的功能沒有出現在COM對象中
<ClassInterface(ClassInterfaceType.AutoDispatch), ProgId("LPFPasserelle.FicheEtablissement")>
Public Class FicheEtablissement
Private mCreateInstitution As New CreateInstitution
<ComRegisterFunction()>
Public Shared Sub RegisterClass(ByVal key As String)
Dim sb As StringBuilder = New StringBuilder(key)
sb.Replace("HKEY_CLASSES_ROOT\", "")
'// Open the CLSID\{guid} key for write access
Dim k As RegistryKey = Registry.ClassesRoot.OpenSubKey(sb.ToString(), True)
Dim ctrl As RegistryKey = k.CreateSubKey("Control")
ctrl.Close()
'// Next create the CodeBase entry - needed if not string named and GACced.
Dim inprocServer32 As RegistryKey = k.OpenSubKey("InprocServer32", True)
inprocServer32.SetValue("CodeBase", Assembly.GetExecutingAssembly().CodeBase)
inprocServer32.Close()
k.Close()
End Sub
<ComUnregisterFunction()>
Public Shared Sub UnregisterClass(ByVal key As String)
Dim sb As StringBuilder = New StringBuilder(key)
sb.Replace("HKEY_CLASSES_ROOT\", "")
'// Open HKCR\CLSID\{guid} for write access
Dim k As RegistryKey = Registry.ClassesRoot.OpenSubKey(sb.ToString(), True)
'// Delete the 'Control' key, but don't throw an exception if it does not exist
If k Is Nothing Then
Return
End If
k.DeleteSubKey("Control", False)
'// Next open up InprocServer32
Dim inprocServer32 As RegistryKey = k.OpenSubKey("InprocServer32", True)
'// And delete the CodeBase key, again not throwing if missing
inprocServer32.DeleteSubKey("CodeBase", False)
'// Finally close the main key
inprocServer32.Close()
k.Close()
End Sub
我添加的消毒字符串數據的功能如下。
Function SanitizeStringData(ByVal StringToSanitize As String)
Dim mSanitizedString As String = String.Empty
mSanitizedString = Trim(StringToSanitize)
If Trim(StringToSanitize).Contains("'") Then
mSanitizedString = Trim(StringToSanitize).Replace("'", "''")
End If
Return mSanitizedString
End Function
您是否在註冊新註冊之前取消註冊舊程序集?您是否確定在註冊時指向新的程序集? – 2014-10-07 20:41:58
是的。註銷和註冊是從批處理文件完成的。我甚至去創建和註冊.tlb文件,但似乎沒有任何工作 – Jay 2014-10-13 14:26:00