You could also create a SerializationBinder that can bind one Type (based on a string) to another Type. Cata's advice is best, though, and is common - especially when doing .NET Remoting. You have a shared assembly that contains the Types (which is a name, assembly, version, culture, and public key token) that both client and server use. This is the correct approach. Using a SerializationBinder is more for upgrading serialized documents between versions, or when you absolutely have to use a Type that you can get access to otherwise.
Search the C# forum for SerializationBinder for a previous discussion I was involved in some time back.
how could i use the mschart in a c# code ,,,i simply need to give my chart 2 columns(coulmn 1 actual cost,coulmn 2 actual cost) ,i need axis y only with millions,and i 've the coulmn value in variables plz answer me quickly..
You must set ColumnNumber and RowNumber first. ColumnNumber is the number of kind of data ( in simple, total color that you see in chart ). The RowNumber is the total data that you want to show ( Default : R1, R2, R3 , ... ). To fill the data you can do this.
//Fill the first column, the second row
myChart.Column = 1;
myChart.Row = 2;
myChart.Data = 25;
NOTE : The property name may be wrong as I don't remember it precisely. But that is the main idea in using ActiveX MSChart.
I have a tab control which initially has one tab page. I want to dynamically create some more tab pages which should have the same controls as the first one.
To read the controls on the first page I am doing the following :
Control myObjArray = new Control[this.tabControl1.TabPages.Controls.Count];<br />
The problem is, when I try to add the controls obtained using the above method, the controls are removed from the first page.
Control NewControl = new Control();<br />
NewControl = (Control)myObjArray[nCount];<br />
This method however successfully puts the controls on the newly created page.
Any ideas how I can have the controls on both the pages ?
Control objects are reference types, and by they can only belong to one parent (typical in a window manager). You're not actually cloning these controls so they are getting re-parented in the new TabPage.
Perhaps a better - more object-oriented - approach would be to subclass TabPage and initialize all the controls in the constructor (like VS.NET does when you add controls to a Form, UserControl, etc.). Then you simply need to instantiate and add your custom TabPage class. New instances of all the controls in each separate instance of this custom TabPage class will already be there, just like instantiating multiple instances of some Form you created.
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.