|
thanks for the reply.
I agree with you that it should be a basic requirement. But the solution, which i am working on, is upgraded from VS 2003 to 2005 to 2008. so, no tablelayoutpanel in 2003. Now planning to localize the app.
|
|
|
|
|
I hope you get paid by the hour!
|
|
|
|
|
|
Nope. There's just no easy way to do this. You've got about a thousand forms to go through. Even if you had an automated way to do it, you'd still be going through a thousand forms to check the automated processes work.
|
|
|
|
|
I have a Reference Question. I am faily new to C# so this might be a very basic question. I have my references folder in my project. I can add and delete them as needed. But I am trying to add two references that have the same name but different version numbers. But I need both because the both do something different for me. Is there a way to add a reference that is the same name and type but a different version number?
What I am trying to do is connect to a COM server. The Reference is to the COM type library so that I can access it and get all of the data out of it. The problem being is I am supposed to support two versions of the same server. When I try to add the reference it states that the type library already exists. When I add the reference I add it from the location on my C drive and it adds it to my project. Is there a way not to add it to my project, but point to it with a path and take whatever reference I need whenever I need it and not have it part of my project?
|
|
|
|
|
The problem you're looking at is those two libraries are using the same GUIDS, so, there's no way for Visual Studio to tell the difference between the two. You're only option is to use all late-binding methods to use these libraries, but that's going to be VERY painful to write. You won't have any Intellisense support at all. It'll be like writing code in Notepad.
|
|
|
|
|
What exactly is a late-binding method? How would I set it up so that I can use these methods? Are there any examples out there?
|
|
|
|
|
Late Binding is, when your code runs, the objects and methods are not exactly known before hand. You ahve to create the objects, then manipulate them using methods that lookup and execute the object's methods and properties, kind of like this[^].
The problem with the example listed is that it won't work with your problem because in order to create the object "Excel.Application", the COM component must be registered. Since your two component most like have the same names, you can't register them both. Or can you?? You'll have to investigate this yourself since we know nothing of your components.
I seem to remember a brief foray into registrationless-COM a few years back, but I haven't heard anything about it since. This involves writing managed C# custom wrappers around the COM components, but documentation and tools on the technique are just about impossible to come by now-a-days, so I think this is a dead end.
|
|
|
|
|
Here is the code.
object padobj = System.Runtime.InteropServices.Marshal.GetActiveObject("PowerPCB.Application");
padsApp = (PowerPCB.Application)padobj;
View.Doc.padsDoc = padsApp.ActiveDocument;
View.Doc.padsDoc.SelectionChange += new PowerPCB._PowerPCBDocEvents_SelectionChangeEventHandler(eeSelection);
padsApp.UnlockServer();
If you notice I am setting padsApp to the the object. But I have to cast the object to PowerPCB.Application. The problem that I am running into is the PowerPCB reference has two versions. I have no problem connecting to the loaded PowerPCB reference, but when I try to connect to the other version I crash when I try to use the padsApp object because I am not using the correct version of the PowerPCB reference. But if I change out the reference and restart the program I am able to connect to the other version just fine. So basically there is no way to point to a reference in a specific location and use that specific reference? It has to be loaded into my project?
|
|
|
|
|
SRogers88 wrote: I have no problem connecting to the loaded PowerPCB reference, but when I try to connect to the other version I crash when I try to use the padsApp object because I am not using the correct version of the PowerPCB reference
You can't do it this way. You're going to have to create two seperate wrapper projects. The first is going to have to reference the first version of this COM server and the second is going to have to reference the second version. You need to set references to the .DLL files themselves and not to what you find under the COM tab in the Add Reference dialog box. You're then going to need to re-expose the classes, properties, methods, and events you want to use for each version of the servers, as appropriate.
Then, when you get both servers wrapped, you'll add references to both of your wrapper projects and use those COM servers through the wrappers. There is no guarantee this is going to work though. You're going tohave to experiment with this yourself to find out.
|
|
|
|
|
I was asked this recently, and I'm not even sure if I understood it correctly. Hope someone can understand / explain what was asked and hopefully try to answer the question:
Let's say I use someone else's unmanaged code. I cannot see that code. Is there anything I can do after calling this unsafe code to make sure that the managed code did not leak memory?
|
|
|
|
|
No, not reliably. You simply have to trust it. If you use the library as documented, you have to trust that it's managing it's resources properly.
|
|
|
|
|
Hi,
I work with RS232 printers and sometimes they have just a few changes in the serialport configuration, like one has Parity=Even and other has Parity=None, or sometimes in the baudrate.
My questions are:
1) Does SerialPort has any builtin function that could read this configuration, without me changing it manually (I can change the port name manually of course)
2) If not, does anyone have ever implemented such feature? What would be a nice (and safe) approach for that?
Thanks,
Dirso
|
|
|
|
|
AFAIK rs232 is too legacy an interface to advertise its connection settings. Unless there's another app involved that sends the config changes to the printer and keeps a record i believe you're SOL.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
|
First explain what do you want to archive clearly
and the second thing refrain from using words like "it's urgent!!!"
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hesham Yassin wrote: it's urgent!!!
That's just plain rude. Your urgency is not anyone else's problem.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
|
Don't expect anyone to help you on this site with an attitude like that.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have a frmMain which has a StatusStrip on it. Inside my class I have a function which checks for internet connection and when the system is not online, I would like for it to update one of the labels on the StatusStrip. I have tried to do some searching and have tried some examples but can not seem to get it to work.
I created the below function in frmMain.cs
public void Set_StatusStrip(string status)
{
toolStripStatusInternetConnection.Text = "";
}
In inc_functions.cs I have the following function
public void InternetConnectionAvailable()
{
frmMain.Set_StatusStrip("Application Online");
}
The error I get is "An object reference is required for the non-static field, method, or property." Can anyone see what I am doing wrong?
|
|
|
|
|
In the "IntererConnectionAvailable" method, you need to be calling Set_StatusStrip on an instance of the form, not on the form class
Object test = new Object();
Object.TestMethod1() <-- Static Method
test.TestMethod2() <-- Instance method
You are calling it as if it was a static method, but it's not, it's an instance method.
Good luck.
(This is a bad design by the way. You shouldn't be using a helper object to set a UI property on the form. Consider reading up about MVC, MVP or other GUI patterns)
Simon
|
|
|
|
|
I have read that it is bad practice, but I have been searching and reading all morning and I can not seem to find anything that is helping me do this the correct way. Can anyone help out with this?
|
|
|
|
|
You could do something like
public void InternetConnectionAvailable(frmMain f)
{
f.Set_StatusStrip("Application Online");
}
And when you call InternetConnectionAvailable , you pass an instance of your frmMain.
|
|
|
|
|
He's trying to avoid bad/not-recommended practices and this is one of those - why on earth would his Connection class or this particular method in it need to know about the form? It's nothing to do with the connection. Events/delegates are the way to handle this scenario.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
This is a perfect situation for using your own custom event. Something like this:
Create a delegate and event
public delegate void ConnectionChangedEventHandler(object sender, ConnectionEventArgs e);
public event ConnectionChangedEventHandler ConnectionChanged;
and a ConnectionEventArgs class
public class ConnectionEventArgs
{
public ConnectionEventArgs(bool isConnected)
{
m_IsConnected = isConnected;
}
private bool m_IsConnected;
public bool IsConnected
{
get { return m_IsConnected; }
}
}
then make the InternetConnection call a method
private void InternetConnectionAvailable()
{
OnConnectionChanged(new ConnectionEventArgs(true));
}
protected virtual void OnConnectionChanged(ConnectionEventArgs e)
{
if (ConnectionChanged != null)
ConnectionChanged(this, e);
}
Now you can subscribe to the ConnectionChanged event and update the StatusStrip
MyClassInstance.ConnectionChanged += new MyClass.ConnectionChangedEventHandler(MyClassInstance_ConnectionChanged);
void MyClassInstance_ConnectionChanged(object sender, ConnectionEventArgs e)
{
}
[edit] This is (obviously) also reusable for when it's not available too
private void InternetConnectionUnavailable()
{
OnConnectionChanged(new ConnectionEventArgs(false));
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
modified on Thursday, October 16, 2008 1:07 PM
|
|
|
|