2013-08-20 3 views
0

Я пытаюсь добавить ссылку на файл из army.mil, corpscon_v6.dll в мой проект .NET.Добавить ссылку на более старую DLL в .NET Application

При добавлении файла в нем говорится: 'corpscon_v6.dll не удалось добавить. Убедитесь, что файл доступен, и что он является допустимым компонентом сборки или COM. ' Затем я запустил Dependency Walker и обнаружил две проблемы внутри DLL: IESHIMS.DLL и WER.DLL не найдены. Я искал эти DLL, и кажется, что они не нужны. Я также боюсь загружать любые DLL-файлы, подобные этому, из разных сайтов, потому что я не могу им доверять, и многие сайты говорят, что не делают этого.

Далее я запустил tlbimp.exe для преобразования DLL, но это тоже не сработало. Это возвращается с ошибкой: входной файл 'c: \ temp \ corpscon_v6.dll' не является допустимой библиотекой типов. Я также попытался сделать regsvr32 на нем, но это возвращается с ошибкой «точка входа не найдена». Учитывая, что я провел время с полностью сломанным армейским корпусом, я нахожусь на полной стене, как получить свою грандиозную CORPSCON DLL, работающую в моем проекте/

+2

Это не будет работать, вам придется использовать PInvoke. Сайт настолько тяжел, чтобы вам помочь. Существуют примеры деклараций [доступно здесь] (http://www.utteraccess.com/forum/lofiversion/index.php/t1948435.html), но они являются объявлениями VB6, которые вам нужно будет преобразовать в VB.NET. Long = Целое число. –

+0

ВЫ СДЕЛАЛИ ДЕНЬ! После того как я изменил типы данных от long до int, это сработало! Большое вам спасибо за вашу помощь. Я был так расстроен, и теперь все кончено! :) – wayofthefuture

+0

У меня не было идеи использовать PInvoke. После того, как вы отправили мне эту ссылку, я попробовал код и не добился успеха. Итак, я начал изучать ошибку, которую я получал от этого кода, и нашел того, кто сказал, что это сработало после того, как они переключили тип данных. Я до сих пор не знаю, что такое PInvoke LOL ... – wayofthefuture

ответ

0

Надеюсь, это поможет. Все это работает для меня до момента получения ответа. Возможно, вы можете понять, что этот старик не знает о материалах C. Good Luck

Импорт System.Runtime.InteropServices

Модуль Module1

<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 

End Module

Смежные вопросы