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?
I use Guid for my Table instead of autonumber in my database table. I show this table in a grid.When I use autonumber it generate primary key in datagrid of my application,now here there is no number and it doeasn't happend and when user add a new row in datagrid of my application they get error that this record is null. How can I handle it so Guid automatcly generate in datagrid like autonumber.Any idea?
For an MS Access database to do this, it doesn't appear to be possible. You can, however, store a GUID as a Text field in MS Access. If you're using a DataGrid, you can use Guid.NewGuid when a new row is created (handle the DataTable.RowChanging and check that Action is DataRowAction.Add - this only works if using a DataSet or DataTable).
Having the client generate the Guid will further ensure that the GUID is unique, since they are mathematically proven to be unique on different machines, but fast generation on a single machine can produce the same GUID (and we've verified that with our own tests).