We've looked into their product and it is very good. Why not use it?
In any case, they use the same concepts that my article discusses. In this case, however, the serial number is used as the validation key or the IV (initialization vector), not sure exactly which. You still have a private key such that you're the only one that can created signed files.
I recommend you at least download their trial and try it out. As I mentioned before, even signing a serial number isn't enough; you must also collect some sort of identity information to tie that serial number to a particular persona, machine, or domain. Otherwise, nothing is stopping someone from giving just the license file to someone else and it will still work without such identifying information.
.net doesn't has common dialog box for functionality "Open With"
How do I display it in the application if the file type is not registered to open by default with any application?
Can anybody give me any pointers
Thanks & Regards
I've got an interface i've constructed in C# for a COM object, IShellFolder. Now I need to construct a pointer to an address that will be used to store the IShellFolder interface.
The problem is, that i have not got a clue how to do this. If it was a structure or base type, i would construct a new one and marshal it, but I don't know how this works for Interfaces. I've looked through the Marshal methods, but not found any that look like they can help.
I've added the attributes of COMInterface.IUnknown, and also the GUID number, to the interface, but i'm uncertain as to where to go from here.
Was using an In where i should have been using an Out.
Next problem: Now I have an IntPtr to an interface, how do I marshal it to the interface I have constructed? I'm currently looking at: GetObjectForIUnknown, but i don't think that is what I'm looking for.
I get the impression from what I have read so far that I need to construct some kind of COM object and tie the interface too it, but I don't know what object IShellFolder is attatched to, and it's not in the documentation. Or I could be way off the mark.
You want Marshal.GetTypedObjectForIUnknown, for which you provide a Type parameter. Just look at all the methods on the Marshal class so you have some idea of what's there.
Since you've posted so many questions about COM with .NET, you really should read a book if you're having trouble understanding this. As I mentioned before, having a COM background helps. If you don't, try this: COM and .NET Component Services[^] from O'Reilly.
Also, instead of using out IntPtr as the param type to SHGetDesktopFolder that you seemed to have defined yourself, just use IShellFolder as the param (no out or ref) and it should work just fine. Marshaling done by the CLR will take care of most of this.
Thanks mate, figured it out on my own just as you posted
I'm just going through the Platform SDK documentation and converting anything I come across to C# COM. No particular purpose really, just learning about it. Very interesting, and i'm getting to grips with it quite nicely bar this small hickup.
It won't, so long as you don't cause an overflow. While the -1 (Int32) is 4,294,967,295 (UInt32), the number is still 0xffffffff. It's not uncommon to use ing instead of uint for parameter types like DWORDs. Even Microsoft does it when manually declaring COM interfaces that they use internally (or those few in System.Runtime.InteropServices that you can use).
Your TestClass has no constructor, so the framework makes a default one for you. It has to call the base contructor. The BasicClass has no default constructor because you defined a constructor with an argument.
publicclass TestClass: BasicClass
// Create a default constructor that explicitly// calls the existing basepublic TestClass() : base("")
// Create a default constructor in the base class.public BasicClass()
this.name = "";
public BasicClass(string name)
this.name = name;
I've build in .NET C# kind of wrapper object to my old COM server (it simply contains that COM server interface pointer inside and exports almost the same properties/methods outside redirecting all calls to that COM interface). Definitely, in order to use COM server in .NET I've generated interop for it. My wrapper resides in its own assembly which uses in runntime (as I supposed) that interop but, the problem appears when I compile module which uses my wrapper: C# compiler asks to add to reference that COM interop also because it can't find definition of that internal COM interface!?. My question is why in compile time C# compiler has to know about internal implementation of my assembly ? I do not export any interface or type from that COM interop, moreover the purpose of this wrapper is to hide COM implementation !.. Is it any way to include that interop in my assembly?.
Because the interop assembly is a dependency of the assembly containing your wrapper, which is a dependency of the assembly using the wrapper. Because the wrapper uses the interop assembly internally, it must be able to reference it in order to compile. Even if both of these assemblies are compiled and added as .NET references (as opposed to project references when using all of them in a single solution), the interop assembly is required in order to load the wrapper assembly. It's also possible that you might be using a Type from the interop assembly as a publicly exposed param, return type, interface, or struct so that would force a dependency resolution.
Basically, any dependencies - whether direct or indirect - must be resolvable when compiling and when running, so long as the Type is access (which foces a JIT compilation).
Look, I've cheked my assembly code one more time and see no Type from the interop assembly publicly exposed... The compiler generates error on my wrapper construction (new instantination) line of code and wants to include COM interop in oder to get iterop-wrapped COM interface type which I use internally (as private data member) in my C# wrapper class and in its contructor I create new instance of that COM class...
I simply do not understand something: is it so different from C++ where during compile time it is enough just function declaration... or (just another thought ) it is so similar to C++ inline/template functions where compiler has to read the code of the function in order to generate inline/template implementation?.
Not two assemblies, no, but you can combine zero or more modules in an assembly. A module is the code without the metadata that makes up an assembly. In order to do this, you'd have to use ildasm.exe to disassemble both assemblies, combine the two IL files from each module (from each assembly, paying attention to how IL is formatted), then use ilasm.exe to reassemble after adding the assembly attributes from one assembly to the IL for the other, new assembly that you're creating.
Another way is to just define the COM interop classes, interfaces, etc. yourself, which Microsoft commonly did in the base class libraries. Make sure you understand marshaling and COM interoperability, though. You can learn a lot by looking through the System.Runtime.InteropServices namespace and several other sections of the .NET Framework SDK.