2013-08-20 36 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 

前端模塊

相關問題