I have a dll written in c# (consuming a wcf service), I have registered the dll using regasm and then gacutil but when I've declared my variable type of automation but I can't found the dll registred is there a way to refresh the assembly or did I miss something????
You need to build your .dll assembly in .NET but have it registered for COM Interop. Have you done this? You also need to define interfaces to your class methods in C# to see the methods properly. Have you done this?
Please see the example below of some old VB code that works using COM Interop. I think you may not have defined everything properly in your assembly...
Imports System.Security.Cryptography
Imports System.IO
Imports System.Text
Imports System.Text.Encoding
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
'GUID hard coded to prevent changing on recompile
<GuidAttribute("9a1ebc2c-f02f-463b-876d-b25431f0696b")> _
'InterfaceType is Dual
<InterfaceType(ComInterfaceType.InterfaceIsDual)> _
'Public Interface created with signatures matching methods in class and properties…
Public Interface ICrypto
'Methods
Function EncryptString(ByVal Content As String) As Boolean
Function DecryptString() As Boolean
Function EncryptFile(ByVal Filename As String, ByVal Target As String) As Boolean
Function DecryptFile(ByVal Filename As String, ByVal Target As String) As Boolean
Function GenerateHash(ByVal Content As String) As Boolean
Function StandardBankGenerateHash(ByVal Content As String, ByVal fileName As String) As Boolean
Function SetEncryptionAlgorithm(ByVal value As Integer) As Boolean
Function GetEncryptionAlgorithm() As Integer
Function SetEncoding(ByVal value As Integer) As Boolean
Function GetEncoding() As Integer
Sub Clear()
'Properties
Property Key() As String
Property Content() As String
ReadOnly Property CryptoException() As CryptographicException
End Interface
'Class defined as ComVisible and GUID static
<ComVisible(True)> _
<GuidAttribute("46155048-ff63-4e63-bc1e-f2e32b66e907")> _
<ProgId("Crypto")> _
<ClassInterface(ClassInterfaceType.None)> _
'Public Interface is Implemented
Public Class Crypto : Implements ICrypto
'Have not expanded the region of Class Variables below…
+ Class Variables Regions
#Region "Public Functions"
Public Property Key() As String Implements ICrypto.Key
Get
Return _key
End Get
Set(ByVal value As String)
_key = value
End Set
End Property
Public Property Content() As String Implements ICrypto.Content
Get
Return _content
End Get
Set(ByVal Value As String)
_content = Value
End Set
End Property
Public ReadOnly Property CryptoException() As CryptographicException Implements ICrypto.CryptoException
Get
Return _exception
End Get
End Property
Public Function SetEncryptionAlgorithm(ByVal value As Integer) As Boolean Implements ICrypto.SetEncryptionAlgorithm
_algorithm = value
Return True
End Function
Public Function GetEncryptionAlgorithm() As Integer Implements ICrypto.GetEncryptionAlgorithm
Return _algorithm
End Function
Public Function SetEncoding(ByVal value As Integer) As Boolean Implements ICrypto.SetEncoding
_encodingType = value
Return True
End Function
Public Function GetEncoding() As Integer Implements ICrypto.GetEncoding
Return _encodingType
End Function
Public Function EncryptString(ByVal Content As String) As Boolean Implements ICrypto.EncryptString
Dim cipherBytes() As Byte
Try
cipherBytes = _Encrypt(Content)
Catch ex As CryptographicException
_exception = New CryptographicException(ex.Message, ex.InnerException)
Return False
End Try
If _encodingType = EncodingType.Hex Then
_content = BytesToHex(cipherBytes)
Else
_content = System.Convert.ToBase64String(cipherBytes)
End If
Return True
End Function
Comments
Hanen TALBI
Please see the example below of some old VB code that works using COM Interop. I think you may not have defined everything properly in your assembly...
regasm myNewInterface.dll /tlb:myNewInterace.tlb /codebase
Clearly you would need to have navigated first to the file path where your .dll is otherwise you'll get errors.
Then you should see everything in NAV!
\:D/
regasm myNewInterface.dll /tlb:myNewInterface.tlb /u
Here is My syntaxe used:
Regasm /tlb: AutInvoice.tlb AutInvoice.dll
Gacutil /i AutInvoice.dll
I've tried also this:
Regasm AutInvoice.dll /tlb: AutInvoice.tlb /codebase
Gacutil /i AutInvoice.dll
and the result is : Assembly added to the cash successfully (for both ways) but I can't see it from Navision
Hanen TALBI
InterfaceType(ComInterfaceType.InterfaceIsDual)
Go through the code example I gave you above...
Hanen TALBI
Also I am not sure about the;
http://blogs.msdn.com/b/nav/archive/2008/12/03/automation-objects-in-microsoft-dynamics-nav-2009.aspx
Hanen TALBI
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!