|
mark_key wrote:
code snippet for 'loading the records on a background thread'?
Look at ThreadPool.QueueUserWorkItem[^] to spawn a thread to execute in the background. That link includes examples in C# and VB.NET how to use the ThreadPool class to execute a function on the background thread.
For you, you simply need to load your XML records in that function. (You said you're already loading the XML records, so I assume we're on the same page there.)
mark_key wrote: code snippet for 'paging data in the grid'?
I rarely use the DataGridView myself, but a quick Google search revealed several articles on CodeProject (complete with source code) regarding how to do this, including this promising one[^].
|
|
|
|
|
I have a main form which launches a second form. The problem is that the second form is always over the first one.
I would like to have them act independently.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
God is the only being who, to rule, does not need to exist. -- Charles Baudelaire
|
|
|
|
|
I guess you use ShowDialog() method to show the second form. Instead of that call the Show() method
|
|
|
|
|
I use the Show(). I can give input to the main form, but the second one always overlap it, unless I drag it so it does not overlap.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
God is the only being who, to rule, does not need to exist. -- Charles Baudelaire
|
|
|
|
|
Then you have to set location of the second form so that they don't overlap
|
|
|
|
|
So if a form launches a second one, the first one can never overlap it? Like switching from one to the other by clicking on the title bar?
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
God is the only being who, to rule, does not need to exist. -- Charles Baudelaire
|
|
|
|
|
If you create the second as a child of the first, it will always be above it. If you don't specify a child, they will interchange with one another, based on what you click.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Aaaaaaaah thanks!
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
God is the only being who, to rule, does not need to exist. -- Charles Baudelaire
|
|
|
|
|
I develop an application that uses a plugin interface, that the hosting application as well as the plugins implement. Each plugin is loaded via:
newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.G etType(pluginType.ToString()));
(mainly an implementation of http://www.codeproject.com/csharp/PluginsInCSharp.asp
All Plugins are inside a sub directory called "plugins" of the main application.
Now I developed one plugin that should implement a network interface, using external dll's from a framework i wrote some time ago. This framework binary serializes objects, compresses them and sends them over the net. There is a central object library of all sendable objects in a seperate dll.
When I receive such an Object in the Plugin, i can deserialize it without any problem and it is showed correctly while debugging as "object" type (resulting from the deserialization). Now, when I try to cast this object to a structure (that is described in the external dll - the object library - which is the same at the sending and receiving side) i get a "Invalid Cast Exception" in the plugin.
By the way, the object and it's type look correctly while debugging and, i can send such objects from this application to the remote one, that also can cast them, using exact the same dll (the object library).
I searched around a lot, but found no real answer...
Maybe the problem is that "Activator.CreateInstance" loads the plugin assembly into a wrong appDomain, because the remote application does not use plugins and refers to the object library - dll directly.
The hosting application as well as the plugin reference the object library dll, and the dll file is present in the main application directory as well as in the plugins subdirectory.
The source code is a bit complex, so i hope that someone might be able to help me just with this description of the problem.
Thx in advance,
Gerd
|
|
|
|
|
Gerd,
You said you tried casting the loaded IPlugin to type to a structure described in the external dll. Is the plugin dll's IPlugin implementation actually a type of the structure you're casting to? I'm a little confused by your post - if you can clarify a bit, maybe show the source code (or the skeleton, e.g. class inheritance) of the external dll's IPlugin implementation, that may help.
|
|
|
|
|
Ok, sorry, the question was not quite clear as I can see now.
Here's the cut-down problem:
There is a Main Program (exe), a Plugin dll, and an object library dll.
The Program loads and instances the Plugin dll, that works fine and is not the question.
But assume that I now have an object passed to the Plugin over the net.
The object is constructed using a class or structure defined in the object library dll on a remote computer.
I now try to cast the object to it's class / struct from within the plugin:
using objectLib;<br />
<br />
public void inputObject (object myObject) <br />
{<br />
objectLib.myClass newClass = (objectLib.myClass)myObject;
}<br />
During debug, myObject.GetType() results in "objectLib+myClass", what should be fine...
When I create a test object locally, say:
<br />
objectLib.myClass testClass = new objectLib.myClass();<br />
then testClass.GetType() also returns "objectLib+myClass", but neither
myObject is objectLib.myClass nor
myObject.GetType() == testClass.GetType()
returns true.
When I use this code only in an exe, without the plugin interface, it works fine.
|
|
|
|
|
Aha, now I understand.
First question is obvious: why is inputObject method taking an object, and not a objectLib.myClass object? My bet is, if you changed the parameter to type objectLib.myClass, the issue will resolve itself through compiler errors leading you to the real problem.
As far as the real problem goes, 2 possibilities come to mind. The first is versioning issues: is the remote process that invokes inputObject built with the exact same version of the object library? Perhaps you could check this by seeing if
myObject.GetType().Assembly == testClass.GetType().Assembly My guess is that the assemblies don't match either, which could indicate different versions of the same assembly; e.g. Main App is using objLib version 2, but the remote process is using objLib version 1.
What I recommend here is making both the main program, the remote process (server?), the plugin dll(s) and the object library all be single projects but under a single solution in Visual Studio, then just reference the projects as needed.
The other thing that comes to mind is AppDomain weirdness. Unfortunately, I'm not experienced with AppDomains enough to give you any meaningful help. The most I can say is, I'm doing something similar to what you're doing (e.g. having a remote process pass a shared object to another process, and it does indeed work).
|
|
|
|
|
I will test the assembly check tomorrow, maybe something will show up there.
The reason for using the object type is, that there are actually several types possible, and the action performed in inputObject depends on the object's type. Why? Because all network communication is performed using (compressed) binary serialized objects...
I tried to copy the objectLib dll from output directory manually and replace all occurrences, but that wasn't successful - so i think that the problem has to do with paths to the plugin etc...
The thing that confuses me a bit is, that although myObject has the correct type (name) - i get the Invalid Cast Exception. So appDomain should be the problem i think...
Maybe someone out there is aware of it...
Gerd
|
|
|
|
|
Ok, finally a figured out what was going on:
Although all used object library dll'd were the same, the hosting application as well as the plugin had a referenced objectLib.dll in the assembly path, say:
bin/debug/objectLib.dll and
bin/debug/plugins/objectLib.dll
Somehow .net used the one in
bin/debug/objectLib.dll to deserialize the object, but for casting, it was using
bin/debug/plugins/objectLib.dll . Using strong names did not resolve the problem either, so i finally referenced the objectLib.dll for the Plugin directly to the one in
bin/debug/objectLib.dll and selected "Copy Local = False".
And suddenly everything was working fine...
Maybe someone will find this solution usefull
Gerd
|
|
|
|
|
Are you using the same dll for both the first creation and the typecast? It sounds like you may have different versions of the same object (if you compile the dll twice, even if the code is identical, you could end up with different object types). I would try to send the object using xml serialization, then put a break point on the receiving end to see that something serialized from that side has the same version and publicKeyToken as the one being received.
|
|
|
|
|
It also looks like newPlugin is a singleton. Could it be that you are sending two types of plugins but then casting to a different type? For example, maybe you have the following...
interface A { }
struct B : A { }
struct C : A { }
newPlugin.Instance = new B();
newPlugin.Instance = new C();
C foo = (C)newPlugin.Instance; // Throws exception if you can only assign Instance property once
B foo = (B)newPlugin.Instance; // Throws exception if the second assignment overwrites the first
Also, it would be helpful to look at the output of ".GetType().FullName" from the immediate window while running, so you know what type you are dealing with.
|
|
|
|
|
thank you, but its not the type of plugin I'm dealing with. Please have a look on my previous answer, I've tried to clearify the problem.
|
|
|
|
|
Hello
I can't find the event lostfocus in txtbox
and i need to correct how the value will be display if the user didn't put it in the correct way and want to leave.
Thanks a lot
Assaf
|
|
|
|
|
The event is called Leave, I believe.
You can change the value in the textbox on the leave event
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you Christian
We called the event is leave and the lostfocus is a property ?
Assaf
|
|
|
|
|
No, the Leave event ( if I've got it right ) is called when a control loses focus. There is no 'lostfocus' property. The object sent to the event is the control that has lost focus.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
I suggest using the Validating event instead of Leave. This adds the possibility to cancel the action if the value can not be formatted correctly.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
I would like to pass a collection of classes as part of the parameters for the constructor of a class.
It was suggested to use an arraylist.
How does it fit within my code?
public class Table
{
public Table (Database _database, string _tableName)
{
}
}
public class Column
{
public Column ( ref Database _database,
ref Table _table,
ref string _dataType,
ref string _columnName,
bool _primaryKey,
string _fkReferences)
{
}
public Column ( ref Database _database,
ref Table _table,
ref string _dataType,
ref string _columnName,
ref bool _primaryKey)
{
}
public bool PrimaryKey
{
get
{
return PrimaryKey;
}
set
{
PrimaryKey = value;
}
}
public string fkReference
{
get
{
return fkReference;
}
set
{
fkReference = value;
}
}
}
Jon
|
|
|
|
|
If you can't use .NET 2.0, I'd recommend wrapping the arraylist in a typesafe class. either way, it becomes another member variable, which is set by another parameter added to your constructor.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|