Hi all, I have a problem with COM , i have create a dll with visual basic, to weight machine, but when i want to read the value from axapta , the COM work , but when i call the method an error tell me that that method non exists. Someone can help me Thanks Many Advance Andrea // code void new() { COM c = new COM(‘jpk.class1’); _com = c; } void start(int portNo) { ; _com.start(1); //error }
if you created a dll, try using dll calls. Look at winapi methods. they all call external DLL functions. in looks like this: //This return true, if a file or directory exists. #define.sizeofStruct(200) client server static boolean folderExists(filename fileName) { DLL _winApiDLL = new DLL(#KERNELDLL); Binary bname = new Binary(fileName); DLLFunction _fileOpen = new DLLFunction(_winApiDLL, ‘OpenFile’); int handle; Binary of = new Binary(#sizeofStruct); ; _fileOpen.returns(ExtTypes::DWord); _fileOpen.arg(ExtTypes::Pointer, ExtTypes::Pointer, ExtTypes::DWord); handle = _fileOpen.call(bname, of,0x4000); // OF_EXIST if (of.dWord(#offset2) == 2) return false; return true; }
thanks for all, but the problem is not solved, the function show me that dll exist, i check also in the registry if it’s correct the name and i try also call the com with te progID, but the result is the same the object COM is created but the method that i call ’ start’ not work and return error. thanks Andrea
Hi Andrea, Apparently in another newsgroup (Technet) a user had the same problem. And he managed to over come this by doing the following - He has created one class in Axapta with the following code - ~~~~~~~~~~~~~~~~~~~~~~~ // classDeclaration public class Class1 { COM aCom; } // method new void new() { aCom = new COM(‘ClassLibrary1.Class1’); } // method method1 void method1() { aCom.method1(); } ~~~~~~~~~~~~~~~~~~~~~~~ And then from second class, he simply instantiates the first class. Like this - ~~~~~~~~~~~~~~~~~~~~~~~ Class1 myClass1; myClass1 = new Class1(); myClass1.method1(); ~~~~~~~~~~~~~~~~~~~~~~~ I haven’t tried it. Perhaps you might give it a try. Regards, Harish Mohanbabu
Thanks for the suggest, I try but the problem is not solved too my method in dll is follow: this method is write on the form of vb6 but i create my project as dllActiveX // methos in dll Public Function start(port As Integer) As Double On Error Resume Next MSComm1.Settings = “1200,n,7,1” MSComm1.CommPort = 1 MSComm1.Handshaking = “0” MSComm1.DTREnable = True MSComm1.RThreshold = 51 MSComm1.SThreshold = 1 MSComm1.NullDiscard = True MSComm1.RTSEnable = True MSComm1.PortOpen = True start = 10 On Error GoTo 0 End Function Thanks for all Andrea
Were u successful in calling your COM object from a vb client? Thanks and Regards, Dilip