|
You wrote earlier "some of the forms in my app", do they have something in common,
maybe a common ancestor (other than Form) ? If so, I would try the DesignMode test in there.
Luc Pattyn
|
|
|
|
|
That's a good thought, but no.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
You should even try the DesignMode test before InitializeComponent:
if your form includes a problematic control (most likely a UserControl), its creation inside
InitializeComponent could fail or throw.
Luc Pattyn
|
|
|
|
|
Hello,
If this is the case he would have seen some exception occuring as he tested to connect with a second instance.
I also wrote the article and the idea of DesignMode.
I have to say that I'm not a friend of this "workarounds".
I'm working alot with usercontrols and inherited controls, which are than been placed in an other Usercontrol, ....
And I think, this is the problem of the DesignMode property, in thoose cases (UserContol1 on UserControl2 on Form) you will get a "false" back from the property.
Not so long ago I searched and removed every "DesignMode" usage in my project and tried to find the real proplems.
Most time it's been done by a "if!=null" statement.
To sumup, I have no solution, but I think workarounds are not working forever.
All the best,
Martin
|
|
|
|
|
Hi,
I did not intend to suggest to permanently put an if(DesignerMode)return; in the code;
my intention was just to help pinpoint where exactly things start to go wrong,
expecting that info would point to the real problem, and hopefully the real solution.
So there is no workaround involved, just a plan of attack.
In general, I would try not to add if statements at all: the more of them, the harder it
gets to test all cases, and to understand what goes wrong when things starts to fail...
Luc Pattyn
|
|
|
|
|
Luc Pattyn wrote: I did not intend to suggest to permanently put an if(DesignerMode)return; in the code;
my intention was just to help pinpoint where exactly things start to go wrong,
expecting that info would point to the real problem, and hopefully the real solution.
I really didn't wanted to pick out your statement.
It was just a general statement which followed what has been discused so far.
Luc Pattyn wrote: In general, I would try not to add if statements at all: the more of them, the harder it
gets to test all cases, and to understand what goes wrong when things starts to fail...
Again a nice summary!
All the best,
Martin
|
|
|
|
|
I need to generate some reports in XLS format and I want to code something in C# that will allow me to manipulate the files. I have seen some basic read/write solutions on this site. I am interested on how i can change the color of a specified cell int the spreadsheet or merge a few cells . Any help or link is greatly appreciated.
|
|
|
|
|
Hello,
I have a question. I want to make a small designer for my application. For that I use the DesignSurface class. this all works very fine, but now I have one small problem too. The standard view (surface.View) has as background another control and the real control which I design is not on (0,0) . For some reason I need the position of (0,0) for the control to design. Knows anyone a solution for this?
Regards
Hansjörg
|
|
|
|
|
Hi guyes
Does anyone know how to convert the data in a dataset into an array.
All the best
Al
|
|
|
|
|
array of what? datarows, strings, objects?!
anyway you have to iterate through Rows in Tables in the dataset adding data to desired array
life is study!!!
|
|
|
|
|
how to create Create Windows User Account or Windows Administrator Account through C# programming.
Sanjit.rajbanshi@wlinktech.com
|
|
|
|
|
first of all read : http://www.codeproject.com/script/comments/forums.asp?forumid=1649&mpp=50&select=1278604&df=100&noise=1#xx1278604xx
then i guess the easiest way is to use Process.Run("net","...");
Process is in System.Disgnostics.. the "..." is the syntax of 'net' command, if you don't know it Start->Run-> "cmd" -> type: "net /?"
life is study!!!
|
|
|
|
|
|
yes. make the object public and add a refernece.
|
|
|
|
|
Nonsense! You cannot make an "object" public, you can make a "class" public.
What she is looking for is called "IPC" - Inter Process Communication. Take a Google search for it [^].
|
|
|
|
|
You need to provide more info. Do you want to pass an instance of an object between apps, or do you want to create a class, and use instances of that class in different apps ? Or something else ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi Christians,
There is one application which is developed totally on c#. At runtime I want to make use of one of the objects of these application from another application that too is developed in c#. But in the first application I cannot make any modification or the channel informations are not available otherwise I could have used remoting. There is a method "GetActiveObject" but it is working only for unmanaged objects (I think). Is there any method equivalet to this which can give the referece of the active or running objects?
Thanks
Diana.
|
|
|
|
|
OK, you want to access an object, an instance of a class, inside another app ? You really cannot. If you can't change the program, there is absolutely no way you can pull an object out of it. The other program needs to anticipate and respond to your attempts to communicate.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Ok, Thanks.
But how is it possible with "GetActiveObject" method for unmanaged objects?
Diana.
|
|
|
|
|
I've never used them, but it looks to me like they work with COM objects. A COM object has a defined public interface, the author has already defined a method to interact with an external program.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
FYI...
It is possible to attach a dll into a process from a different process and invoke a static method available with that dll. So it is possible to enter into a process and do whatever there, though we can't access the data back to the attaching process. If interested to know more see the article ".NET Object Spy and InvokeRemote".
Thanks
Diana.
|
|
|
|
|
Are your applications all on the same machine?
You might want to try Enterprise Services.
.Net remoting also works well and you can setup singleton objects which would be shared by all connecting clients.
Services are useful if you want highly persistent objects. maybe combined with one of the methods above.
Persisting the objects to an XML file or database might work if your design is very simple.
As always the solution depends on what you are trying to achieve.
HTH
Russ
|
|
|
|
|
Hi Russ,
Bothe applications are running on the same machine. As I don't know the channel informations, I cannot use remoting as well as I cannot modify the application. I would like to know is there any method similar to "GetActiveObject" available for this?
Thanks
Diana.
|
|
|
|
|
When an exception is thrown in my application I use a PropertyGrid to dynamically show the exception to the user, allowing him to inspect all details.
I also log the exception to a log file (through LOG4NET).
Now I would like to be able to not only log the standard properties of the catched base Exception object but also any (nested) properties of derived exceptions (e.g. the Response property of a WebException and therein the ResponseUri property of that Response property).
Question: How can I do this in a "generic" way?
I already started doing some simple reflection but didn't manage to detect the type of the property and to decide whether to dig deeper or simple to call and output the ToString() method.
Any hints, please?
|
|
|
|
|
Hello,
I'm not sure if I complettly understand the complexity of your question.
I'm using Reflection in combination with Cloning of UserControls, where I whant to get the public properties values.
Works like this:
using System.ComponentModel;
PropertyDescriptorCollection pdcMyControl = TypeDescriptor.GetProperties(MyControl);
foreach(PropertyDescriptor pdMyControl in pdcMyControl)
{
System.Type pd_typ = pdMyControl.PropertyType.GetInterface("ICollection");
if (pd_typ != null)
{
ICollection ItemsMyControl = pdMyControl.GetValue(MyControl) as ICollection;
foreach (object obj in ItemsMyControl)
{
}
}
else
{
}
}
Maybe it helps!
All the best,
Martin
|
|
|
|