2013-08-20 37 views
0

我想添加一个引用从army.mil,corpscon_v6.dll一个文件,我的.NET项目。年长DLL添加引用在.NET应用程序

当添加的文件,它规定:“无法添加corpscon_v6.dll。请确保文件是可访问的,并且它是一个有效的程序集或COM组件。'接下来,我运行了Dependency Walker,发现DLL中有两个问题:找不到IESHIMS.DLL和WER.DLL。我已经搜索这些DLL的,似乎他们不需要。我也害怕从其他网站上下载任何类似的DLL,因为我不能相信它们,许多网站都说不这样做。

接下来,我跑tlbimp.exe是对DLL进行转换,但是这也不能工作。这会返回一个错误:输入文件'c:\ temp \ corpscon_v6.dll'不是有效的类型库。我也尝试过对它做一个regsvr32,但是这带着'入口点找不到错误'。考虑到我已经花在处理与彻底打破军团的网站的时候,我在与如何让我的项目/

+2

这是行不通的,你将不得不使用的PInvoke。该网站很难帮助你。有样本声明[可在此处](http://www.utteraccess.com/forum/lofiversion/index.php/t1948435.html),但它们是VB6声明,您必须将其转换为VB.NET。长=整数。 –

+0

你节省了这一天!在将数据类型从long更改为int之后,它起作用了!非常感谢您的帮助我一直非常沮丧,现在已经结束了! :) – wayofthefuture

+0

我不知道使用PInvoke。在你寄给我这个链接之后,我试了一下代码,但没有成功。于是我开始研究我从代码中得到的错误,并发现有人说在切换数据类型后它工作正常。我仍然不知道PInvoke是什么LOL ... – wayofthefuture

回答

0

希望这有助于他们的宏伟CORPSCON DLL工作一个完整的墙。这一切对我来说都很有效,直到找回答案。 也许你可以弄清楚这个老人不知道C的东西。 好运

进口System.Runtime.InteropServices

模块模块1

<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="SetInSystem", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function SetInSystem(ByVal InValue As Integer) As Integer 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 


<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="SetInDatum", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function setindatum(ByVal InValue As Int16) As Integer 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 
<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="SetOutDatum", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function SetOutDatum(ByVal InValue As Int32) As Integer 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 

<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="SetOutSystem", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function SetOutSystem(ByVal InValue As Int32) As Integer 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 



<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="Corpscon_initialize", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function Corpscon_initialize() As Double 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 


<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="GetXOut", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function GetXOut() As Double 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 


<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="SetOutZone", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function SetOutZone(ByVal InValue As Int32) As Integer 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 

<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="SetXIn", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function SetXIn(ByVal InValue As Double) As Integer 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 


<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="SetYIn", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function SetYIn(ByVal InValue As Double) As Integer 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 

<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="corpscon_initialize_convert", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function corpscon_initialize_convert() As Integer 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 

<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="SetOutUnits", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function SetOutUnits(ByVal InValue As Int32) As Integer 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 

<DllImport("c:\Develop\CorpsCon\corpscon_v6.dll", EntryPoint:="GetYOut", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> 
Public Function GetYOut() As Double 
    ' Leave function empty - DllImport attribute forces calls 
    ' to Corpsconconfig to be forwarded to MoveFileW in KERNEL32.DLL. 
End Function 



Public Sub convertDegreestoMeters(ByVal inx As Double, ByVal iny As Double, ByRef outx As Double, ByRef outy As Double) 
    Dim RetVal As Integer 

    RetVal = SetInSystem(1) 
    RetVal = setindatum(1983) 
    RetVal = SetOutSystem(2) 
    RetVal = SetOutDatum(1983) 
    RetVal = setoutzone(2301) 
    RetVal = setoutUnits(3) '1=US Servey Foot, 2=International Foor,3=Meters 

    RetVal = corpscon_initialize_convert() 

    RetVal = SetYIn(iny) 
    RetVal = SetXIn(inx) 
    Dim script As String 

    RetVal = corpscon_initialize_convert() 

    Dim outdbl As Double 
    outdbl = GetXOut() 
    script = "<script language=JavaScript>window.alert('" & outdbl & "'); </script>" 
    'ClientScript.RegisterStartupScript(Me.GetType, "tab3", script) 
    outx = outdbl 

    outdbl = GetYOut() 
    script = "<script language=JavaScript>window.alert('" & outdbl & "'); </script>" 
    'ClientScript.RegisterStartupScript(Me.GetType, "tab4", script) 
    outy = outdbl 

End Sub 

Sub Main() 
    Dim outx As Double = 0 
    Dim outy As Double = 0 
    Call convertDegreestoMeters(CDbl(88.5555), CDbl(27.5555), outx, outy) 
    'Results SHOULD BE Outx= 
End Sub 

前端模块

相关问题