Register dll!!!!
Hanen
Member Posts: 281
Hello,
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????
Heeeeeeeelp!!!!!
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
Heeeeeeeelp!!!!!
Regards
Hanen TALBI
Hanen TALBI
0
Comments
-
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?0
-
Yes I've did all this steps
Regards
Hanen TALBI0 -
Are you sure?
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 Function0 -
Also what is your regasm syntax? Also not sure you need to bother with gacutil...0
-
Your syntax should be something like...
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/0 -
Oh and to unregister the above then simply;
regasm myNewInterface.dll /tlb:myNewInterface.tlb /u0 -
My dll is written in c#
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


Regards
Hanen TALBI0 -
Have you checked this property in your interface declaration... I have seen this requires setting before... -
InterfaceType(ComInterfaceType.InterfaceIsDual)
Go through the code example I gave you above...0 -
Here is the code:
[ComVisible(true)] [Guid("0E3DBBD5-B0B8-43b2-8C53-78AABA6EA69F")] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IFactureCRM { //********************************* Traitement des Tarifs **************************************** bool GetConnection(string URL, string Login, string MP, string Domain); bool CreationFacture(string CompteF, string NumFre, string MontantFre); }//fin interface ITarifCRM [ComVisible(true)] [ComDefaultInterface(typeof(IFactureCRM))] [ClassInterface(ClassInterfaceType.None)] public class FactureCRM : IFactureCRM { //********************************* Traitement des Produits **************************************** public string AdressUrl = null; public string Password = null; public string DomainWCF = null; public string UserName = null; public bool GetConnection(string URL, string Login, string MP, string Domain) {//Préparer les params de connexion AdressUrl = URL; UserName = Login; Password = MP; DomainWCF = Domain; return true; }//Fin GetConnexion //Modifier le code afin de passer l URL, password, username et Domain en paramètre public bool CreationFacture(string CompteF, string NumFre, string MontantFre) { EndpointAddress ead = new EndpointAddress(AdressUrl); NetTcpBinding tcpbd = new NetTcpBinding(); ChannelFactory<ControlFacture.ServiceFacture.IServiceFacturation> proxy = new ChannelFactory<IServiceFacturation>(tcpbd, ead); proxy.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; proxy.Credentials.Windows.ClientCredential.Domain = DomainWCF;//"MACHINE-TEST"; proxy.Credentials.Windows.ClientCredential.UserName = UserName;//"administrateur"; proxy.Credentials.Windows.ClientCredential.Password = Password;//"M%test6"; IServiceFacturation chanel = proxy.CreateChannel(); decimal Montant; Montant = Convert.ToDecimal(MontantFre); Facture F = new Facture(); F.CompteFacturation = CompteF; F.NumFacture = NumFre; F.MontantFacture = (double)Montant; FacturationResponseInfo respInfo; respInfo = chanel.CreationFacture(Origine.Billing, F); if (respInfo.Code == 0) return true; else return false; }//fin CreationFactureRegards
Hanen TALBI0 -
On your Project->Properties in Visual Studio have you ticked "Register for COM Interop"
Also I am not sure about the;[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
0 -
I've got it from this link:
http://blogs.msdn.com/b/nav/archive/2008/12/03/automation-objects-in-microsoft-dynamics-nav-2009.aspxRegards
Hanen TALBI0 -
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision Classic Client' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions