|
Thanks for the help! Our code is not the same Luc, but I see what you were trying to do so I am going to play with that. I can't thank you enough for the quick response! Thanks again!
Dan
|
|
|
|
|
My mistake. It should be CheckBox . Updated the post.
|
|
|
|
|
Well I know only objects are garbage collected, but please hear me out..
I have a class "serverClass" in my program.cs file in a project. All the members of this class are static, moreover the members of this class are DLLIMPORTS of an unmanaged Dll. This file also has the IDE generated "Program" class which has the Main() function that invokes the Form1 GUI i.e.; Application.Run(new Form1());
Now, I have the Form1.cs file with Form1 class that has buttons and listboxes. The Form1 class has the button events, etc, i have also created a couple of member functions in the Form1 class (startServer() and stopServer()). These functions call the static members of the "serverClass" from the program.cs file. But as I said earlier the serverClass is static class and hence I cannot create an instance to access its functions, instead I go serverClass.function1() (i.e.; className.memberFunction()), serverClass.function2(), etc.
I want to access the startServer() and stopServer() functions on the click of the buttons "Start" and "Stop" respectively. So in the click events of these buttons I call these functions.
The project compiles fine. When I run the application/form and click 'Start' button the startServer() function is called and the server runs fine as desired. But my problem is when I click the 'Stop' button and the stopServer() function is called, I get a runtime error "CallbackOnCollectedDelegate" on the line in the stopServer() function where I call a member of serverClass as serverClass.function2().
I might be wrong in the class structuring itself....I appreciate all the suggestions and ideas.
BTW all of the mentioned classes are in the same namespace.
|
|
|
|
|
Without seeing any code, all one can do is guess. Maybe you have some local variables inside your static methods, say a delegate inside serverClass.Start() which is passed to some unmanaged piece of code, and hence all managed references to it are lost, so the next time around the GC will throw it out?
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Yes that was my guess too, the serverClass.Start(), takes a variable serverID so it is actually serverClass.Start(serverID); so I defined this variable in the serverClass as public and I use it in the functions as serverClass.Start(serverClass.serverID); and just to verify I tried printing this variable right before the line of error and it prints fine. As a matter of fact I tried accessing another function of serverClass from this position too, this function just reads some data that does not have anything thing to do with server creation or destruction and it works fine too.
But the combination; serverClass.Stop(serverclass.serverID); is problematic.
If the serverID is ok and serverClass.anotherFunction() is ok then what might be the issue???
|
|
|
|
|
1. again[^]
2. IMO things that have state should not be modeled as a static.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Thank you for your efforts, but I am bound not to release the code.
I tried making the serverClass as non static and defining its functions and variables as non static too but then: The DllImport attribute must be specified on a method marked 'static' and 'extern'
Oh this is something...
|
|
|
|
|
one more thing to add here, in the original console based application (c#), both the start() and stop() functions are in the main() and after the start() initiates, the console waits for the user to hit return (Console.readline()) and then the stop() function initiates.
All this works very fine in that application. I just wanted them to initiate on the click of the buttons.
|
|
|
|
|
Hi,
I am getting an exception in the following code. Exception is "Could not load file or assembly 'AutomationAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c1461fa3837aae41' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)"
AssemblyName _asmName = new AssemblyName();
_asmName.CodeBase = "file://" + "D://dinesh//CSharp//AutomationAddIn//AutomationAddIn//bin//Debug//AutomationAddIn.dll";
Assembly.Load(_asmName);
Any suggestions?
Thanks.
|
|
|
|
|
"file://" is not necessary
only two letters away from being an asset
|
|
|
|
|
what's with all those double slashes? it is backslash that needs escaping, not slash.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Hello
Is there anyone out there that knows how to develop the connection points that indicate relational mappings between two objects.. example: C# dataset designer can indicate foreign key relationships, or MSSQL diagrams also have the same connecting points that are adjustable. Adjustable by means of it not always being a straight line at all times..
So i'm building a busines object modeller and require the ability to show relational connection points on my business objects on a designer canvas. This leads my to believe that a implentation of maybe IDesignerHost is valid, but i would not know where to start with those connecter objects..
The connecting points must indicate what type of relationship it it and also must be adjustable when moved by using the mouse..
any ideas where to start.. please help.
Regards
|
|
|
|
|
You could always start by downloading Netron[^], and having a look to see how this was solved there.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi All,
In my text box i need to allow alphanumerics and some special characters. Below is the code i used in Regular expression valiadator -it works perfectly fine.
"^[0-9a-zA-Z,@&_.-]+$"
I need to allow spaces in textbox. so can anyone please help me how to add it. I tried to add a space in the above existing validation but throws an error. Help required in this. Thanks in advance.
Thanks,
Santa.
|
|
|
|
|
Did you try with \s for the white space?
How does your code look like?
|
|
|
|
|
How to add the \s in the above expression. I added in many ways and saw it was not working.
Thanks,
Santa
|
|
|
|
|
can anyone plese help me in this issue.
i am struck here ..
requirement --- need to allow spaces text box so to need to add code for it in the regular expression validator.
Thanks,
Santa
|
|
|
|
|
This code:
Regex rx = new Regex(@"\s");
string test = "1234 abc";
if (rx.IsMatch(test))
Console.WriteLine("White space");
else
Console.WriteLine("No white space");
gives the output: White space for me.
|
|
|
|
|
can you please tell me how to add this \s in this expression
"^[0-9a-zA-Z,@&_.-]+$".
Thanks in advance.
Thanks ,
Santa
|
|
|
|
|
I think you need to learn a little bit about regular expressions, as it is simple to add the \s to your expression. Try looking at Expresso[^] which is a tool for creating, testing and examining regular expressions.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
suppose i have one form with one button and i want when i will click the button then mouse will go to a folder and double click on it to open. so please someone tell me how can i do this programatically.
i need this type of idea for developing screen sharing apps. i can develop apps with remoting that which run in client machine and capture client screen and send the scree to my apps and then my apps paint its screen with that image. it is easy but suppose client desktop has one folder called test and when i will click on the picture of that test folder from my end then what i need to send as a result apps in client end can programatically open that folder.
please i need good idea to move in right direction to develop a screen share apps. please give me the idea that how to open folder of client machine after clicking on the image of client desktop transferred by apps sitting in client machine.
i will be highly obliged if anyone can help me to develop this apps with idea and also can tell me if is there any site available from where i can download the sample code.
Thanks in advance
tbhattacharjee
|
|
|
|
|
i written following code under printDocument1_PrintPage event
Font f = new Font("Arial", 14, FontStyle.Regular);
Brush b = Brushes.Black;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
for (int j = 0; j < dataGridView1.Columns.Count; j++)
{
e.Graphics.DrawString(this.dataGridView1(i, j) + " ", f, b, j * 5, i * 5);
}
}
i am getting error this.dataGridView1(i, j)
error message isError 1 Non-invocable member FormsApplication2.Form1.dataGridView1' cannot be used like a method.
please help me .
|
|
|
|
|
The part of your code that is giving the error is
e.Graphics.DrawString(<big>this.dataGridView1(i, j)</big> + " ", f, b, j * 5, i * 5);
You are using this.dataGridView1(i, j) as if there were a DataGridView method that takes a row index and a column index and returns the value stored there. There is no such method.
You need to use square brackets '[]'.
Like this:
e.Graphics.DrawString(<big>this.dataGridView1[i, j]</big> + " ", f, b, j * 5, i * 5);
but as you have it you will get incorrect results, as it is dgrid[colindex, rowindex] and you are using dgrid[rowindex, colindex]
You can use something like
e.Graphics.DrawString(this.dataGridView1.Rows[i].Cells[j].Value.ToString() + " ", f, b, j * 5, i * 5);
so that you do not get confused about cols and rows.
Note also the .Value.ToString() in the last bit of code, you may, or may not need to use it in your code.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
I developped a windows service and I'd like to retrieve its own credentials (the "Run As" credentials, not the WindowsIdentity). Is it possible?
If yes, can those credentials be converted to NetworkCredentials? (for webservices calls)
thanks
|
|
|
|
|
Hi,
I have a scenario where I'm validating the data in a text box for special character.
The user can enter the data through keyboard, Copy & paste data using Ctrl+C and Ctrl+V from keyboard, or right click and paste using mouse.
I have to validate the data before it is pasted to the textbox. I'm validating the data for first two scenarios, i.e., validating while user enteres the data, or pasting the data using Ctrl+C and Ctrl+V from keyboard.
I'm not able to find any events which triggers contextmenu_paste_click event.
I'm not allowed to create a context menu for the textbox, that is I have to use the default context menu and I cannot create a new class which inherits the textBox class.
How can I implement this?
Any suggestion is appreciated.
Thank you.
|
|
|
|