|
Sorry Steve.
Im new to the message posts.
I will follow ur guidelines for sure from next time.
Coming to our discussion, iam getting the message box only once,
meaning that only one byte is marshalled.
|
|
|
|
|
Post the entire IDL file.
Steve
|
|
|
|
|
 ENTIRE IDL File:
import "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\prsht.idl";
import "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\mshtml.idl";
import "c:\program files\microsoft visual studio .net 2003\vc7\platformsdk\include\dimm.idl";
import "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\mshtmhst.idl";
import "c:\program files\microsoft visual studio .net 2003\vc7\platformsdk\include\docobj.idl";
import "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\exdisp.idl";
import "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\objsafe.idl";
[
object,
uuid(A12EAEC2-2B64-470B-93AF-EFE0855DD3AC),
dual,
helpstring("IDataProvider Interface"),
pointer_default(unique)
]
#line 14 "d:\\vc++\\sample applications\\bytcomp\\dataprovider.h"
interface IDataProvider : IDispatch {
#line 16 "d:\\vc++\\sample applications\\bytcomp\\dataprovider.h"
[id(1),helpstring("method GetSafeArray")] HRESULT GetSafeArray([out,retval] VARIANT *vtSafeArray);
[id(2),helpstring("method SetByteData")] HRESULT SetByteData([in] BYTE *bytArray);
[id(3),helpstring("method SetArray")] HRESULT SetArray([in]BSTR bstrArray);
[id(4),helpstring("method SetThings")] HRESULT SetThings([in]BYTE **ppThings );
[id(5),helpstring("method SetData")] HRESULT SetData([in] ULONG size, [in,size_is(size)] BYTE *pData);
};
[ version(1.0), uuid(0381FBF3-32C1-4AF1-B6DD-EFB51815DD72), helpstring("BytComp 1.0 Type Library") ] library BytComp
{
importlib("stdole2.tlb");
importlib("olepro32.dll");
[
version(1.0),
uuid(8816EAAA-91D5-4DCF-BA1A-DD699529D099),
helpstring("DataProvider Class")
]
#line 36 "d:\\vc++\\sample applications\\bytcomp\\dataprovider.h"
coclass CDataProvider {
interface IDataProvider;
};
}
|
|
|
|
|
Ok. Open the registry editor and search for the following key:
{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}
If you find if right click on it and select "Export". Post the contents of the file this generates.
Steve
|
|
|
|
|
Hi Steve, i found two registry entries..
1st Entry
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Interface\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}]
@="IDataProvider"
[HKEY_CLASSES_ROOT\Interface\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}\NumMethods]
@="12"
[HKEY_CLASSES_ROOT\Interface\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}\ProxyStubClsid]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_CLASSES_ROOT\Interface\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}\ProxyStubClsid32]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_CLASSES_ROOT\Interface\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}\TypeLib]
@="{0381FBF3-32C1-4AF1-B6DD-EFB51815DD72}"
"Version"="1.0"
2nd Registry Entry:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}]
@="PSFactoryBuffer"
[HKEY_CLASSES_ROOT\CLSID\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}\InProcServer32]
@="D:\\VC++\\Sample Applications\\BytComp\\DebugPS\\BytCompPS.dll"
"ThreadingModel"="Both"
|
|
|
|
|
First note that the proxy-stub you built is creatable:
K ARUN KUMAR wrote: [HKEY_CLASSES_ROOT\CLSID\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}\InProcServer32]
@="D:\\VC++\\Sample Applications\\BytComp\\DebugPS\\BytCompPS.dll" "ThreadingModel"="Both"
But your interface isn't using it:
K ARUN KUMAR wrote: [HKEY_CLASSES_ROOT\Interface\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}\ProxyStubClsid32]
@="{00020424-0000-0000-C000-000000000046}"
{00020424-0000-0000-C000-000000000046} is the universal marshaller, not your proxy-stub ({A12EAEC2-2B64-470B-93AF-EFE0855DD3AC} ).
Also I notice your interface is marked with [dual] . This means the interface has to be automation compatible and should only use a limited number of types (which doesn't include BYTE arrays).
Do you get warnings when you compile the IDL file? Did you ignore them?
Since you exported these keys you're free to tinker with them as they can easily be restored using the exported files.
Change this key:
[HKEY_CLASSES_ROOT\Interface\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}\ProxyStubClsid32]
@="{00020424-0000-0000-C000-000000000046}"
So that it looks like this:
[HKEY_CLASSES_ROOT\Interface\{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}\ProxyStubClsid32]
@="{A12EAEC2-2B64-470B-93AF-EFE0855DD3AC}"
NOTE: Don't alter the exported files, make the changes in the registry. Alternatively copy the exported file, make the change in the copy, then double click the copy.
Steve
|
|
|
|
|
Hi Steve,
You are amazing. The change worked.
But when iam building the server,
it again modifying the registry
setting to default Marshaller GUID.
How to set my ProxtStub GUID as default?
|
|
|
|
|
The problem is your interface is marked as an automation interface but it uses types that are not automation compatible. As I said, I'm sure the MIDL compiler would have warned you about this, and you should always investigate compiler warnings. The are a number of ways to fix this:
- Don't use an automation compatible interface. Remove the
dual and all the [id] attributes, and derive from IUnknown instead of IDispatch . You will not need the IDispatchImp base class in you server implementation either. - Add another interface to the object (which isn't
dual and derives from IUnknown , as described above) to contain the non-automation compatible methods. - Manually make the changes I described after RegisterTypeLib[^] makes the "wrong" ones. This is a hack though: why use an automation-compatible interface that automation clients will not be able to call?
- Give my posts good marks
Steve
|
|
|
|
|
Thanks a lot buddy.
Sure..
Arun
|
|
|
|
|
Hi,
I've a windows class library and would like to create ActiveXControl for that. I regstered the dll using RegAsm.exe and created the below html in local IIS(wwwroot) and accessed. But its not showing the design.
Please let me know if I missed any steps in creation of ActiveXControl. Thanks in advance.
<html>
<body color=white>
<hr>
Please note that you MUST load this HTML document from your local IIS, or from a TRUSTED SITE <hr>
<font face=arial size=1>
<OBJECT id="myControl1" name="myControl1" classid="0AE91E82-5EE3-4d27-B7ED-CE2C0B059BB7" width="500" height="200">
</OBJECT>
</font> <hr>
</body> </html>
classid is the GUID of the class.
In one of the class, I declared the GUID as below.
[ Guid("0AE91E82-5EE3-4d27-B7ED-CE2C0B059BB7"),
InterfaceType(ComInterfaceType.InterfaceIsDual),
ComVisible(true)]
|
|
|
|
|
<object id="myControl1" classid="CLSID:0AE91E82-5EE3-4d27-B7ED-CE2C0B059BB7" <="" object="">
Also, if your activeX is not signed, ensure your browser's security level is set to low, and unsigned activeX controls are allowed to load.
|
|
|
|
|
I tried the above as per your message. Still the problem exists..
|
|
|
|
|
Hello,
Instead of IDispatch, If I have some COM component that exposes its methods through IUnknown, can we call its methods at runtime? Problem is Invoke memeber only available in case of IDispatch
Regards
Usman
|
|
|
|
|
Hello,
I am getting address of COM function by loading type library (TLB) and iterating over types using ITypeLib and ITypeInfo.
After calling AddressOfMember function of ITypeInfo I am facing following exception:
System.Runtime.InteropServices.COMException (0x800288BD): Wrong module kind for the operation. (Exception from HRESULT: 0x800288BD (TYPE_E_BADMODULEKIND)) at System.Runtime.InteropServices.ComTypes.ITypeInfo.AddressOfMember(Int32 memid, INVOKEKIND invKind, IntPtr& ppv).
Any idea how to get rid of this excpetion?
for (int curFunc = 0; curFunc <iTotalfunc ; iTotalFuncs;curFunc++)
{
try
{
IntPtr ppFuncDesc;
oTypeInfo.GetFuncDesc(curFunc, out ppFuncDesc);
funcDesc = new System.Runtime.InteropServices.ComTypes.FUNCDESC();
funcDesc = (System.Runtime.InteropServices.ComTypes.FUNCDESC)Marshal.PtrToStructure(ppFuncDesc,typeof(System.Runtime.InteropServices.ComTypes.FUNCDESC));
int cNames;
//if (funcDesc.)
oTypeInfo.GetNames(funcDesc.memid, m_strFuncNames, 1, out cNames);
switch (funcDesc.invkind)
{
case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_FUNC:
//Console.WriteLine(" (method)");
//_infoType = "Function";
//_property = false;
string strSignature = "";
if (funcDesc.cParams> 0)
{
IntPtr addrssOfMember;
oTypeInfo.AddressOfMember(funcDesc.memid, //Here where exception occured System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_FUNC, out addrssOfMember);
}//end of if
}//end of switch
}//end of try
}//end of for
Regards
Usman
-- Modified Friday, May 14, 2010 3:06 AM
|
|
|
|
|
hi,
I need to do language localization using XML in VC++ (MFC).
I need to do mapping using XML file and i need to scan the XML file for the desired language, so that my output would be in my desired language.
I have no idea, how to go about it.
Please Support
|
|
|
|
|
|
Hello,
I need to write type libraries in C#.NET. Type library is of unmanaged COM servers. How..?
Regards
Usman
|
|
|
|
|
Type libraries can be accessed using the ITypeInfo and ITypeLib interfaces.
From C# you can do COM interop to use these interfaces.
Here is a good article on COM Interop[^].
|
|
|
|
|
#include "stdafx.h"
#include "windows.h"
Hi All,
In the below mentioned code. i want to use MSCOMM32.OCX file API to my C++ code.
i am facing an issue when i am getting HResult from the cocreateInstance.
Kindly let me know what should i do to access MSCOMM32.OCX API.
#include "atlbase.h"
#import "C:\\WINDOWS\\system32\\MSCOMM32.OCX" no_namespace raw_interfaces_only raw_native_types no_implementation named_guids
int main(int argc, _TCHAR* argv[])
{
GUID iid = {0xE6E17E90, 0xDF38, 0x11CF, 0x8E, 0x74,0x00,0xA0,0xC9,0x0F,0x26,0xF8};
GUID Clsid = {0x648A5603, 0x2C6E, 0x101B, 0x82, 0xB6, 0x0,0x0, 0x0, 0x0, 0x0, 0x14};
IMSComm **ppv = 0;
HRESULT hRet = 0;
hRet = CoInitialize(NULL);
hRet = CoCreateInstance (Clsid, NULL,CLSCTX_LOCAL_SERVER,iid,(void**)&ppv);
_bstr_t pbstrSettings("9600,N,8,1");
(*ppv)->put_PortOpen(1);
(*ppv)->put_Settings(pbstrSettings);
(*ppv)->AboutBox();
return 0;
}
|
|
|
|
|
The activeX is probably not registered.
Which OS are you using?
Open a command prompt with admin privileges, change to the system32 directory and type the command regsvr32 mscomm32.ocx .
|
|
|
|
|
pallaka wrote: hRet = CoCreateInstance (Clsid, NULL,CLSCTX_LOCAL_SERVER,iid,(void**)&ppv);
As a rule, OCX is an in-proc server.
With best wishes,
Vita
|
|
|
|
|
I have read that COM+ is not portable. It is tightly coupled.
Please provide me a pointer to understand this better.
I gather that, COM+ which is a runtime environment should be tightly coupled
with the operating system.
Why I am confused is because, ultimately COM+ is based on components and
components are binary and ready to use that can move across dlls and
across machines ... so where is tight coupling?
Regards,
Net Questions
|
|
|
|
|
|
Hi Mike,
COM+ runtime environment is supported only by microsoft.
With regards to the component that I create say using the ATL languange or C++, can it or not run on other platforms?
Regards,
Net Questions
|
|
|
|
|
Disclaimer:
I've been breaking into developing via the C# language for about 7 months now, so take it easy on me.
I am writing an add-in to a 3D CAD program called Autodesk Inventor. It has a COM API and they (Autodesk) provide a nice project template to start from which includes the proper references as well as some pre-baked code to get you started. I have been succesfully coding against it for a couple of months now and I have decided to try out the new C# 4.0 language features that just came out with VS 2010. I'm really liking the named and optional parameters, but I digress.
When debugging, I start up an Inventor.exe session which, in short, looks to the registry and finds my add-in and loads it. The problem I'm having is actually hitting a breakpoint in my code while debugging. I have gone through several different property settings on the referenced InventorInterop.dll as well as options on debugging (among other trial and error things), none of which seems to work. The only thing that works is when I go back to an earlier .NET framework (i.e. not 4.0).
I have tried this on other *sample* add-ins that come with the SDK and the same thing happens. The add-in loads and code gets executed, but the breakpoints don't get hit when targeting the .NET 4.0 framework.
Is this a problem with me, the COM interop, or something else altogether?
Thanks in advance.
-Brian Hall-
|
|
|
|
|