I'm converting my idl file to a tlb file, which now works fine. I have the base classes for Drag and Drop in the file, but when I convert it to a dll via tlbimp, i get a lot of errors, that leads me to believe that I am missing out on a large number of type definitions.
Where do I go to import these?
Aditionaly, when comparing my DLL with the windows form DragDrop methods, a lot of my int32's are replaced with UInt32. Why is this the case?
All my return values are void, wheras, in the IoleDataObject, they are almost all exclusively int.
Looking at the reflector decompilation, some of the objects that my version tries to interpret and convert but fails to, are all stored as object, i.e. IEnumStatData and IAdviceSink. How would I set up tlbimp to set it up this way?
Also, many of my types now come with & appended after them when they are used in method descriptions. Why is this?
My compiled version seems to have added object's for all the base types, Bitmap, clip format, metafile, pallete, and a whole heap of IWinTypes and IAdviseSink.
I don't know where these are actualy coming from. Do they exist in the .NET run time assembly already? I thought they did.
By default, tlbimp.exe transforms any method signatures with an [out, retval] parameter such that it because the return type of the method. Since Microsoft developers also typed these methods, you can sometimes get away with returning an int to represent the HRESULT (so it would seem), but you can still return various HRESULT codes by throwing the COMException with an appropriate errorCode parameter value - even success codes like S_FALSE.
As far as all the interfaces that were imported, these interfaces, structs, etc., are used by the interfaces you imported so they must be imported too, being that they are dependend types of the interfaces' methods that you imported (or struct member types, etc.).
If you want more control over the method signatures, you should type them yourself.
So what I have will still work? i'll just have to handle the Uints and IntPtr's differently?
What about deffining the classes that didn't get ported properly?
STGMEDIUM failed completely, and is handled as an intptr. I can define one myself, but I'm curious as to why it failed. I'm not sure where it's declared, as there are many STGMEDIUM type classes declared through the SDK import IDL's, though none actualy follow the name STGMEDIUM or tagSTGMEDIUM directly.
Many of the other interfaces, structs etc, failed to be marshaled, I got a lot of errors that looked like they failed down to a base system type.
Clipformat and STGMEDIUM in particular are my two biggest concerns, and another problem is with a Byte array that used an equation to determine the size.
I will have a crack at porting some of these to C# manualy if the whole tlbimp failes, but i'd like to go back to it due to the fact that I only had a slight brush with it.
(As opposed to MIDL which works fine now I have figured out how things work, but it took long enough)
If you are ready to lose some of your hair, then you can edit the interop assembly (ildasm) by hand and then recompile it with a proper marshalling (ilasm).
Things to know about tlbimp.exe :
- it's a great tool but it doesn't export all of the content of IDL files.
- you need an actual tlb file (embedded or not), if not tlbimp.exe will fail miserably
- The .NET IntPtr type is the lowest common denominator for some struct. It shouldn't be a surprise that tlbimp exports an IDL-defined struct to a mere IntPtr when either 1) the struct is not defined as tlbimp.exe expects it to be 2) the structure is overly complex. Resulting in an IntPtr means that you have to marshal the struct back and forth yourself, that's not a big deal though since the Marshal class in the InteropServices namespace provides the API for just that.
I would like to create a string bitmap and that string should be able to customized by user.
I know I can use Graphics.DrawString() to draw a string over the window, but phycially, I want to generate a bitmap for that. Futhermore, I would like to collect the memory bits of that bitmap, because I need to do some calculations or adjusting its colors .
I am devloping a window form to List the files under a specific folder. I am using FolderBrowserDialog class for user to select a specific folder. Once a specific folder is selected I list all the files under that folder.
My problem is when Folder Browser window opens It does not show the tree view of Directory structure. Just a blank area instead. At the bottom of the window, it shows
three button " Create new folder ", "OK" & "Cancel". Appreciate any help to resolve this problem.
Code for Folder Browser:
FolderBrowserDialog folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
folderBrowserDialog1.SelectedPath = Directory.GetCurrentDirectory();
DialogResult result = folderBrowserDialog1.ShowDialog();
if( result == DialogResult.OK )
directoryPath = folderBrowserDialog1.SelectedPath;
Everything looks right, so you should try debugging. See what the value of folderBrowserDialog1.SelectedPath is after assigning the return value of Directory.GetCurrentDirectory. If you are setting a RootPath (assuming you didn't copy and paste the code fragment directly), make sure Directory.GetCurrentDirectory is a child of that RootPath.
Kinda new to the .NET/C# thing so maybe there's a simple solution for this (I hope). I'm creating a subclass of ListBox, but instead of normal listbox items I want it to display panels (containing various other controls). I know how to make it an "ownerdraw" listbox and I've provided the proper measurements for each panel in the "MeasureItem" override, but I don't know what to do in the "DrawItem" override in order to get the panels to be displayed. How does one do this? All the examples of ownerdraw listboxes I've seen use the Graphics.DrawRectangle(...) and Graphics.DrawString(...), etc., commands to draw things, when I really just want the panel control to draw itself.
I'm working on using RSA encryption in a Form Application. I'm stuck, How do I get access to the Public Key of the Public/Private Key pair ? Can I access it directly through RSAParameters ? I need to be able to send it over a socket.
Can I send the whole RSAParameters class over the socket some how ?
I'm triing to Serialize the RSAParameters Class but ehte resulting buffer is blank:
public byte  GetPublicKeyBuff()
RSAParameters result = new RSAParameters();
BinaryFormatter formatter = new BinaryFormatter();
result = rsa.ExportParameters(false);
Stream s= new MemoryStream();
byte PubKey = new byte[iSize];
BinaryWriter bw = new BinaryWriter(File.OpenWrite("c:\\temp\\test\\pubkey.dat"));
Hello, i am trying to make an application that will be nested within another app and will 1) create a BackUP folder if it doesn't exist, and 2) it will check for a number of files to see which exist and which not in the backup and act as told.
So far i made it check for the backup folder and create one but i can't execute more than one 'if' expression, thus i get stuck with only copying (back up) only one file. here's a fragment of the the code:
So, your array contains on even indices the backup file name and on odd indices the original file name...
From the code you have the easiest change is to delete the else because as soon as the first if condition is satisfied all others will be ignored because that are something "else".
The same would be true of the switch. By the way, Fall through is not permitted in C# switch statements unless is it falling through without doing anything.
// Do somethingcase2:
// This is not permitted because statements exist in the above casebreak;
// This is permitted. 3 falls through because nothing is done until// it gets to 4.break;
Of course you would have to set your array to be the correct length.
When Monty Python meets Star Trek: WHAT is your name? Captain Jean-Luc Picard. WHAT is your quest? I seek the Holy Grail. WHAT is the average velocity of a Bird of Prey? Romulan or Klingon? I ... I don't know AAAAAHHHHH!
I agree that the second solution is better, but I just wanted to point out that you can use goto case # to go to the next case instead of flowing through, which - as you said - isn't allowed.
There was discussion a long time back on MSDN or something as to why Microsoft didn't allow cases to flow through when they even provided a goto case statement; their answer seemed rather pointless. Oh well...
Yeah, Colin, i tried the 'for', loop and it seems to do the job much smoother i get an exception (not crash) when no more files are meant to be copied. i suspect it's because it goes on until it reaches 15 (the total array length starting from 0)
exception: File name cannot be null.
Parameter name: sourceFileName.
Anyway i could work around if no more files are meant to be copied?
Edit: i tried doing:
if (strOFiles = "")<br />
but either "" or 'null', don't work 'cause i canno implicity convert string to bool Any way to make this one work?
Last Visit: 31-Dec-99 19:00 Last Update: 28-Jan-23 17:54