2014-10-07 36 views
0

我在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 
+0

您是否在注册新注册之前取消注册旧程序集?您是否确定在注册时指向新的程序集? – 2014-10-07 20:41:58

+0

是的。注销和注册是从批处理文件完成的。我甚至去创建和注册.tlb文件,但似乎没有任何工作 – Jay 2014-10-13 14:26:00

回答

0

不确定您的消毒DLL/COM的问题,而是你的sanitize串,我不知道为什么你不只是用VFP的功能STRTRAN()

someString = [什么是布莱恩]

? STRTRAN(someString, “'”, “ ''”)

将导致

什么是布莱恩''上

Help on StrTran() function

Another cool one is CHRTRAN(),具有广泛的利益,从通过将字符串中的每个字符替换为其他字符,将字符串中的无效字符剥离为伪加密...

+0

DLL在vb.net中创建并包含捕获和保存数据所需的所有功能。使用此DLL的软件是在vfp中完成的。这就是为什么我没有使用这些功能 - STRTRAN()和CHRTRAN() – Jay 2014-10-13 14:30:16

+0

@Jay ...正确..如果您使用VFP来完成这项工作并调用VB.net DLL,那么您不需要VB .net DLL。这些是默认内置在VFP中的功能,您可以直接使用它们。不需要外部DLL功能。 – DRapp 2014-10-13 15:28:42

+0

我需要实现的任务不能从VFP完成,因此需要.NET dll。 Vfp只是简单地使用dll,因为原始软件是在VFP9中完成的 – Jay 2014-10-14 09:58:41