|
Thank you for your response. I must apologize because I typed my code in incorrectly. I am doing just what you said and it still does not work. See the bottom of my original post. That is what confuses me. The names of each type are the same, but the types are not...
Thanks,
Craig Wilson
|
|
|
|
|
I'm not sure what I did, but it works now. Thanks for your help. Somehow, I think it was getting assemblies mixed up or something. Anyhow, Thanks.
Craig Wilson
|
|
|
|
|
That's what I figured and was about ready to state. Even though a type may have the same namespace and name, a Type is also comprised of assembly information, consisting of the name of the assembly, the culture info, version, and public key token (if strongly named, which assemblies always should be in any production code).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, I'm developing a smart device application in c# at the moment.
I have made a webservice who access my SQL database and returns a DataSet with data (a name and an ID).
The meaning is that the first combobox will fill with the associations, and by choosing an association, the second combobox will fill with the institutions of that association.
In my webapplication, I have databinded this DataSet white success to my dropdownlist, but in this mobile application, I always have an error. (but finally I also receive the right information, my combobox will fill with the right information)
I've catcht the error in a messagebox so my programme won't stop during running, and I found out that during Page_Load() he gives the error catched in ComoboBox1_IndexeChanged().
By starting the application, I get first a few "error2-FormatException" and than an "error1-ArgumentException". Afther that my combobox is filled with my associations. By selecting another association, I get an "error2-ArgumentException" before my combobox is filled with the institutions of that association.
I know it's a long explanation but I've tried everything and all the examples I've found on the internet gives exactly what I have programmed.
Can anyone please help me with it??
Thank you very much
private void Form1_Load(object sender, System.EventArgs e)
{
try
{
Service service = new Service();
DataSet dataset = new DataSet();
dataset = service.getAssociations();
comboBox1.DataSource = dataset.Tables["associations"];
comboBox1.DisplayMember = "cName";
comboBox1.ValueMember = "ID";
comboBox1.DataBindings.Clear();
comboBox1.DataBindings.Add("SelectedValue", dataset, "associations.ID");
}
catch (Exception error)
{
MessageBox.Show(error.ToString(), "error1");
}
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
Service service = new Service();
DataSet dataset = new DataSet();
dataset = service.getInstitutions(Int32.Parse (ComboBox1.SelectedValue.ToString()));
comboBox2.DataSource = dataset.Tables["institutions"];
comboBox2.DisplayMember = "cName";
comboBox2.ValueMember = "ID";
comboBox2.DataBindings.Clear();
comboBox2.DataBindings.Add("SelectedValue", dataset, "institutions.ID");
}
catch (Exception error)
{
MessageBox.Show(error.ToString(), "error2");
}
}
|
|
|
|
|
How would I go about creating a virtual file item in C#?
This is continuing my interest in developing a drag drop feature. Generaly, files are dropped by handling their HDROP, and therefore, i would need to create a file to do this.
However, for dragging and dropping, the process of creating large files prior to the drag proceess would be horribly costly, so i would like to instead create a virtual file type structure that contains binary serialized data, and can be handled like a system file by OLE methods.
Can this be done?
Cata
|
|
|
|
|
You're answer lies in the documentation for the TYMED data type, which is used in the FORMATETC and STGMEDIUM structures which I mentioned to you months ago when you started this venture. You're only three real options besides creating a physical file to hold the file contents is to lock the file contenxt in global memory (bad for large files), or implement IStream or IStorage to pull the file data when requested.
Say you use an IStream (TYMED_ISTREAM ) implementation to "store" your file contents. This is independent of the clipboard format (for which you could still use the CF_HDROP clipboard format). When a drop target says, "hey, I can take a file to be moved or copied", it gets the storage type (TYMED ) from the format info (FORMATETC ) and gets a pointer to that from the storage medium information (STGMEDIUM ). So long as it understands the storage type (which things usually do), it starts making requests on your IStream implementation, which is where you start feeding it information about your file.
That's about as "virtual" as you're going to get, unless you want to go to the practically impossible task of creating a block device in Windows (easy in *nix, NOT easy in Windows).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ahhhh. I thought i should have done it that way, but it wasn't too sure if it was expecting a stream or an actual file object handle.
So the IStream interface can be dropped to shell, and if i handle it with HDROP, it will construct the file for me?
In which case, i need to set the file name(s) via _DROPFILES. (Where is this object placed? Are there two STGMEDIUM objects, one for the stream, one for the descriptor? I'm a bit fuzzy on that issue, i didn't find the documentation on it that helpful)
I need to implement whatever version of IStream i want to use in a C# based object and define the interface behaviour from the managed end. IStream would in this case tie into a stream object created by serializing an object.
However, to handle this custom IStream, i will also need to build a managed DataObject that implements the IDataObject interface, unless I can get a random IDataObject from the shell and use SetData to set my IStream to the item.
That about right?
Dropping INTO managed code is a piece of cake, shame the reverse is such a pain in the a*se.
Cata
|
|
|
|
|
All the IStream implementation (and it does have to be the actual COM IStream interface, or use the UCOMIStream interface in .NET) has to do is provide an implementation that gets the file bytes. The drop target doesn't care where they come from, as long as the object you pass it supports that interface. Your implementation could simply return the file contents in the IStream::Read method.
And yes, you still need to use the various COM interface for DnD because the similarily-named .NET interfaces don't expose what you need. IIRC, you can still use the managed DoDragDrop but you need to use the COM IDataObject interface.
Use .NET Reflector[^] or ildasm.exe (if you can read IL) to look at how Control.DoDragDrop works. It eventually uses the COM interfaces, otherwise it couldn't communicate with anything that is not a .NET application.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
What about the IOLEDataObject?
I have implemented my own managed version, and this one appears to be an unmanaged type that is already registered in the managed DoDragDrop method through casting. If i register my own version of IOLEDragDrop, will it be cast properly by the dodragdrop method? Or do i need to implement a whole new DDD?
Also, where the hell do i declare the name of the file to be constructed? (I think this is the final element of the puzzle, everything else I can do).
As always, thanks for your help.
Cata
|
|
|
|
|
Forget about using managed declarations of unmanaged code already in the .NET FCL assemblies - do it all yourself. Functions like DoDragDrop aren't hard at all. You're making this hard than it really is.
All the IStream implementation is is the storage medium for the file, as opposed to a physical file that already exists or a file locked in globally accessible memory (among other storage mediums that don't really work for most files).
The name can bet set in the STATSTG structure that is used with the STGMEDIUM . See STATSTG.pwcsName for more information. This is returned from IStream::Stat for the implementation used in STGMEDIUM .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
if i just buy a VC++.Net but not the whole Visual Studio.Net
package, can I still use it to develop software for Pocket PC 2003/Smartphone by using the compact framework extension ?
and can I develop software on PocketPC/Smartphone by using
C# ?
Thanks
|
|
|
|
|
I haven't done it myself but I don't think there is problem with that.You can get better answer in VC++ forum.
pyhtang1 wrote:
can I develop software on PocketPC/Smartphone by using
C# ?
Sure.
Mazy
"Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
|
|
|
|
|
Mazdak wrote:
can I develop software on PocketPC/Smartphone by using
C# ?
Sure.
Not if you only buy VC++ though, you'd need Visual c#
|
|
|
|
|
Of course, but I can't see in that statement he mention that.
Mazy
"Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
|
|
|
|
|
Actually, you don't need either. Download the .NET Framework. You've got the C# compiler. Download the .NET Framework SDK for more tools and documentation. You can do the same with Compact Framework (CF). Download the runtime. That's really all you need. You can find all the documentation in MSDN Library[^].
Now, if you can't develop without designers and drag-n-drop, then you'll need to get Visual C# .NET. If you look at the price, by the time you purchase two packages you've just spent more than you would for Visual Studio .NET.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Isn't there an open source IDE for C# development? I can't recall the name. Does that support CF?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
You're thinking of SharpDevelop (#develop)[^], and I don't believe it supports CF designers, but you don't really need them anyway. Drag-n-drop development is not true development. IDE's are handy, but being able to develop without them is what helps make you a decent developer.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Uh oh. You mean using VS.NET will always make me beneath all those who develop by hand?
But I thought that the real essence is not code writing, it's really the thinking behind it, if you know what I mean. This is why IDEs are okay, because they let you concentrate on writing the code that really matters, not the one you know by heart how to write already (like instantiating forms and controls).
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
I'm not saying IDEs are bad, just that good developers can live without them. I use an IDE mostly at work because IntelliSense helps me avoid stupid spelling (rather, casing) mistakes, but I never rely on it (like a lot of people, unfortunately) to tell me what a class supports in the way of method and property names. I know what a class has (good memory helps, but...) and if I don't then I look it up in the documentation to truly understand what's available and what everything does.
Most code I write for CP (especially code snippets I post here in the forums) are written using VIM[^] on the command line with the C# command-line compiler (csc.exe) because it's fast and easy and I don't have to create a project (btw, VS.NET 2005 will have "scratch projects" for this very purpose!).
So, like I said, IDEs aren't bad. They sure save a lot of time when designing forms and creating data classes (like hooking up data adapters to data sets), but they shouldn't be depended on 100%. Knowing how to code and using an IDE doesn't make a good developer. Just look at VB programmers!
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm sorry, did that sound sarcastic? That's not what I meant if it did. It's just that your opinion matters to me, I sort of look up to you!
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Hi All,
Does anyone have a good example of using a COM Scriptlet (mine is VBS) from a CSharp application? Should it would like a normal COM control?
Regards,
Davy
My Personal Blog - Homepage. Scottish News - Angus Blog, Perth Blog and Dundee Blog
|
|
|
|
|
You should be able to. Make sure you register them first using regsvr32.exe. You'll have to create your own interop classes, though, since there wouldn't be any typelib on which to use tlbimp.exe. The WSC host (script.dll) takes care of all the details so the CCW shouldn't care how the COM control was instantiated or where it came from (one of the major development goals of COM).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
|
Hello. I'd like to write a module for IE in order to add custom http headers to each request. Is it possible? Thank you.
|
|
|
|
|