|
Not sure if it's the right way, but the following works for me: Set the dialog's ShowInTaskBar property false, and after creating the dialog (in some method of the main form) call MainForm.AddOwnedForm(DialogForm).
Chris Jobson
|
|
|
|
|
Chris Jobson wrote:
Not sure if it's the right way
Going from memory, the docs for AddOwnedForm say that is what it does so I would say that is The Right Way™
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Thanks for your support too, James.
Cheers
|
|
|
|
|
Thank you Chris, that's exactly what the doctor ordered It's a pleasure to have contributors such as yourself on CP.
Incredible that I overlooked that in the docs; probably scanned the protected methods too quickly, and got lost in keyword searches!
Cheers
|
|
|
|
|
I am trying to get an assembly compiled using the managed compiler and get the resulting class library strong named.
First I tried an explicite path to the file in the assembly. No go.
Now: the assembly info states that the strong name key must be relative to the project location....so I created the location in the assembly file as ..\..\keyfilename.snk and tried to have it find it.
I first tried just locating the strong name key file within the source files and then in the bin file and in both cases the key file is reported as not found by the compiler.
So next I added the path to my source in the /lib: switch for the compiler. This still ended with file not found.
Has anyone gotten a strong named compilation using the managed compiler and how did you get it to find the snk file ???
I am at wits end.
Thanks,
MJ
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
theRealCondor wrote:
..\..\keyfilename.snk
AssemblyKeyFile("..\\..\\mykey.snk")
Is it that simple a problem?
|
|
|
|
|
Robert,
I was shothanding here.
if ..\.. was actually entered into the assemblyinfo file, it would fail with a compile error and never attempt to compile the dll since \. is an invalid control character.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Just put every thing in the same directory and change the assembly.cs file to point to the current directory.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
lippie,
I had put the snKey file, and source files in one directory, and set
[assembly:AssemblyKeyFile("")] to the same directory name.
RESULT: key file could not be found
I had put the snKey file and source files in one directory and set
[assembly:AssemblyKeyFile("..\\..\\keyfile.snk")]
RESULT: key file could not be found
I had put the snKey file in the build directory and set the
[assembly:AssemblyKeyFile("..\\..\\\\keyfile.snk")]
RESULT: key file could not be found
I had put the snKey file in the build directory and directly pointed at
the build directory
RESULT: key file could not be found
I added a compile parameter /lib:"my souce library path"
RESULT: key file could not be found
I am about to put a shotgun in the mouth of the compiler and let it try and find it's brains after I pull the trigger !!!!!
I suspect that the little tidbit in AssemblyInfo where it goes after
%Project Directory%\obj\<configuration> that I am either
a) not getting %Project Directory% set
or b) I am still missing a directive to the compiler (which still goes back to a).
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
I finally got the managed compiler to create a strong named assembly.
What I had to do was as follows:
1) I did a File.Copy to move the SN Key from the selected directory to the
source directory. This was my choice but not necessary.
2) Instead of setting [AssemblyKeyName...]
I had to set [AssemblyKeyFile... and specified the fully qualified path.
[AssemblyKeyFile="D:\myApp\mySource\keyF.snk"]
3) Compile to your hearts content!!!! WOOHOO!
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
I want my program to be able to find a specified window, activate it, and send it keyboard commands. Kind of like a macro program. How would I code this?
|
|
|
|
|
Have a look at the WSH sendkeys functionality.
Not the only way though...
Davy
Blog for Software Testing, Bugs, Quality, Security and Stability - www.latedecember.com
News From Angus, Scotland - The Angus Blog
|
|
|
|
|
My application requires global variables in it(the variable that can be accessed from objects of any class in application).
How to implement such a feature ?
Thanks in advance
|
|
|
|
|
Create a class with static variables maybe... I dont think global variables are possible in C#.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Try something like this:
<br />
namespace MyGlobals<br />
{<br />
sealed public class DaysOfTheWeek<br />
{<br />
public static int nSunday = 0; <br />
public static int nMonday = 1;<br />
public static int nTuesday = 2;<br />
public static int nWednesday = 3;<br />
public static int nThursday = 4;<br />
public static int nFriday = 5;<br />
public static int nSaturday = 6; <br />
}<br />
}<br />
You can reference these variables by name (nMonday, nFriday, etc.) in your other files after adding the following line:
<br />
using MyGlobals.DaysOfTheWeek;<br />
Click here to see my articles and software tools
|
|
|
|
|
You could create an abstract super class that defines the variables that need to be global, then derive all of your classes from that one class.
Alternatively, If you don't need to update the value of the variable, then you could define it in a .config file, and then read the config file from the classes that need to access the variable. If you need to change it or share it between application types (web, windows, windows services, etc.), then define an XML document somewhere on your system and then read from and update it in the classes where you use it.
I'm sure there is probably a better way to do it, but this is my 2c.
RabidK
|
|
|
|
|
Vitaliy Vorontsov wrote:
My application requires global variables
BTW the politically correct name for a global variable is "Well Known Object"
|
|
|
|
|
Robert Hinrichs wrote:
BTW the politically correct name for a global variable is "Well Known Object"
Well said. And there are no global functions either, only statics, which preserve the purity of the OO paradigm.
Cheers
|
|
|
|
|
try http://www.dofactory.com/patterns/PatternSingleton.aspx
It helps with global variables.
|
|
|
|
|
Perhaps this should be in the general .NET forum, but what the heck.
I've written a program, in C#, that runs as a service. I have done the installer so it will install the service on the system.
However what I cannot figure out (and probably because paying for all this Microsoft software made me so broke I cannot afford the approriate book) is how to handle the case where the service is already installed when setup is being run.
The installer will just say "Service is already installed" and rollback the entire installation. What I want to achive is that the executable for the service is updated and the service restarted.
I figured maybe I could do a check to see if the service was installed, stop it and then delete it, before the installer installs the new version,but I can't seem to find a method to actually remove a service from the system either.
Any pointers would be highly appreciated.
/CMH
|
|
|
|
|
|
Hi!
I am quite new to C# and have noticed that one cannot give default values to arguments. Any idea why this is not implementend in C#?
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Alexandru Savescu wrote:
Any idea why this is not implementend in C#?
As I've read, this leads to versioning problems. Where does the default is defined? On the client or in the interface implementation?
It's not the fall that kills you: it's the sudden stop - Down by Law, Jim Jamursch (1986)
|
|
|
|
|
I think I was not clear enough. I meant default argument values to functions like in C++:
void f (int x = 0)
{
printf ("%d", x);
}
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Alexandru Savescu wrote:
I think I was not clear enough.
No, you were. I wasn't, sorry.
This page explains it better than me:
"
Because IL always calls a method passing a complete set of arguments, the value of an absent argument is determined at compile time, not at run time. This has versioning consequences. For example, say a ComponentAssembly.dll assembly contains a method that has an optional Int32 argument whose default value is 5. Now imagine an AppAssembly.exe assembly that contains a call to this method and the optional argument isn’t specified. When compiling AppAssembly.exe, the compiler emits IL code that passes 5 to the method. Let’s say that the method in ComponentAssembly.dll has its optional parameter’s default value changed to 123 and the assembly is rebuilt. If the AppAssembly.exe assembly isn’t rebuilt, then at run time, 5 is passed to the method—the new default value (123) isn’t passed to the method unless the code in AppAssembly.exe is also recompiled.
"
http://www.microsoft.com/mspress/books/sampchap/6199e.asp[^]
It's not the fall that kills you: it's the sudden stop - Down by Law, Jim Jamursch (1986)
|
|
|
|