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?
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.
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">
classid is the GUID of the class.
In one of the class, I declared the GUID as below.
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++)
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));
oTypeInfo.GetNames(funcDesc.memid, m_strFuncNames, 1, out cNames);
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
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.
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?
I believe that I am supposed to create an IVolumeClient object using CoCreateInstance, and then use that object to communicate with the Disk Management server.
My confusion comes when I try to find any kind of interface to IVolumeClient on my development machine. Where would I find a C++ header file for the IVolumeClient interface, and where would the proper CLSID and IID values for CoCreateInstance be found?
Good Question. I've searched the whole DDK, and I can' t find one. the Interface is however defined in full (including CLSID) in the open specification you refer to (look in Appendix A, 6.1 full dmintf idl)
May I however suggest another (supported) approach to this: (the open spec is for information only)
The thing that confuses me is that the documentation states: no client operating systems supported, but this may be an artefact of the age of the documentation (the documentation may not have been updated since this function was implemented, and this may only indicate that at the time of the implementation, there were no clients supporting this).
If you have to go beyond server 2003, you could use FSCTL's to do your mounting, have a look at this article: Inside Mountvol.exe[^] Although this primarily deals with registering the reparse points as a normal user. (this can't be done, for security reasons), however the drive letters (a: b: c: ...) are pre-existing, so they require no privileges to mount. Running you program as administator will help anyway (always needed for the registration of a reparse point).
A lot of this is educated guesswork (I haven't tried it) but this should set you on your way...
Taking it in order.
1) Unmounting the drive will flush the caches. Of course the SCSI standard allows surprise removal so, you never can tell.
2) Issuing SCSI commands. You should be able to issue any SCSI custom command through IOCTL passtrhru interface if the drive is not mounted. How this is affected by security and passwords, I'll be honest: I don't know. You may well require elevated priviliges to do this from user mode.
3) Remounting volumes: should be no problem if you have chosen a drive letter or a reparse point previously. If the drive (well the drives's GUID, really) has not been mounted before, you need elevated privileges to put in the HKLM section of the registry. Also take a look at the automount status (which I think you can see in mountvol, or diskpart. (not too sober myself)).
2B) reestablish write protect. Well I suppose there's a custom SCSI for that one too? Of course if your thingy i s already mounted, you may require elevation. Scratch that, if your drive is already mounted R/W, write protecting it afterwards will cause the file system driver (FAT32, NTFS) to have a nervous breakdown. You won't believe how these things can fill your event log with messages of doom.
Ron Aldrich wrote:
All of this has to work on Windows XP, Windows NT and Windows 7
Which Windows NT? If you're talking about 3.1 or 3.51, I've worn out the CD's to put my ashtray on. (Actually I seem to remember they still came on floppys). Windows 2000 has left supported status when William Shatner had to hand over the keys of the USS Enterprise. Your best bet is XP service pack 3. It postdates server 2003 (when all the goodies were introduced) and should have all the nice OS interfaces, without having to write your own device drivers.
Without user privileges: actually I think this is feasible, providing that you have an install program that handles the messy bits like doing initial mounts, establishing HKLM keys.
Ron Aldrich wrote:
I guess my first task is to determine whether or not this is even possible.
If you're really looking at targeting pre-XP SP3 releases then the Open Specification document to which you referred may be be your only chance. But remember that these open specifications are not cast in stone. These docs were only produced by M$ because they were forced do to so by the EU. Support will be patchy, at best.
If you send me a private reply on this message, you'll get my email address by returning mail. (putting addresses on the internet is never a good idea. (Can I interest you in some Cialis or Viagra?)
PS, to clear some confusion: you don't mount a drive. A drive is a physical thing which contains partitions. A drive is either offline or online. When it's online it can be controlled by the device manager. Partitions can be mounted or dismounted on reparse points (drive letters, empty NTFS directories) when the drive is online...
I am working on a plug-in for IE that can capture and manipulate requests, before sending them to server, just like Tampar IE.
Kindly provide some help in this regard.
A step-by step would be highly appreciated as I am a novice in this domain.