|
I have a dillema: I am writing 2 programs, and among others they use some classes which are the same. I have two choices: copy the cs files to them both, or create a Dll with them? Is it possible to do so? How? Thanks in advance!
|
|
|
|
|
It's possible...
Create a class library project...put your code into it...compile it, then reference the assembly in your other projects.
|
|
|
|
|
Ok, but what means "reference the assembly"?
|
|
|
|
|
Right click on your project in Project Explorer (if you have VisualStudio(.NET) - if not, read documentation to your IDE) and select "Add reference" Then there should be tab "from project" and list of your projects in solution.. select your class library and double click or something (I don't have VS opened now) and you should add reference to your library ( = assembly)
hope it helps.
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
I have a DLL I wrote that uses a web service. I set the 'Web Reference URL' to dynamic. I see in the app.config file that the value is present.
My problem is when I compile the DLL the config file is not generated.
Question #1: Is this normal behavior for a DLL.
Question #2: Could copy and rename the app.config file to '<assemblyname>.dll.config' and the DLL use it normally?
Any help would be greatly appreciated!
Thanks in advance!
I reject to reality and subsitute my own!
- Adam Savage, Mythbuster
life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
|
|
|
|
|
There are no config files for .DLL's like there are for applications (app.config.) Any settings code you write would be looking at the host application's config file, whatever that may be.
And your signature should be fixed:
I reject your reality and substitute my own
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
Any settings code you write would be looking at the host application's config file, whatever that may be.
I thought that to, but it doesn't seem to be true. So I guess the only true way of doing this would be to modify the Web Reference source file and modify it's constructor to require the URL to the web service. The only problem with this solution would be when you update the web reference then this file would be recreated and the changes would be lost.
As for my signature, the quote is correct as stated. Pay close attention to the opening of Mythbusters.
|
|
|
|
|
Why don't you have your own .config XML file, and access it like XML file not like config file? e.g. with XPath document... or am I missing something badly??? (I admit I more read that sig/quote part )
jklucker wrote:
As for my signature, the quote is correct as stated. Pay close attention to the opening of Mythbusters.
Yeah you won[^]
Looks like you are both wrong, guys... Dave with quote and you because you misspelled word "substitute" ;P
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
You are right I can create my own config file and access like XML. I was looking to use the app.config functionality that System.Configuration.AppSettings gives us access to.
I like the google fight, I never heard that before. I'll have to remember that.
It just goes to show how spell checkers are relied upon.:->
I reject to reality and subsitute my own!
- Adam Savage, Mythbuster
life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
|
|
|
|
|
Im making a game, but i need to give different objects different depths, y'know so you could walk BEHIND a tree or something.
I just need to know how you do it.
With game making software (which im not using right now)
You can give the tree a depth of 50 for example and the guy a depth of 60, the guy would walk behind the tree right. Or if the guy had a depth of 40 he would walk infront of it.
So any ideas?
I also would like to know how to have a window that follows the character around a larger room, this is necessary because i cant fit the whole of one 'room' on the screen and you need to be able to see what your doing, so any info on that would be good to.
|
|
|
|
|
This could be answered in many different ways depending on the technology you're using. GDI+? Windows Forms? DirectX's Direct3d? Managed DirectX? DirectX's DirectDraw? OpenGL? A 3rd party 3d engine? A 3rd party 2d engine?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
Oh sorry 'bout that im just using directX and its a 2D game so ya dont need to worry about any 3D type things.
|
|
|
|
|
Then it'd just be a matter of drawing one object after another. Objects that are "deeper" in the scene (i.e. have a greater z buffer) would be drawn first, while objects shallower in the scene (i.e. have a smaller z buffer closest to 0) would be draw last.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
So basically, create my own int called depth or whatever, and when my character gets past the tree (int is greater than the trees) re-draw the tree.
Even simpler than i thought.
|
|
|
|
|
You need to setup a Depth order. often this is as easy as starting your drawing from the upper left. But if your using a more 3d approch then you need to setup a list of items to draw by there depth. Draw the farthest objects first. The simplist way is create a static list. When you load your map organize the list for all you static (non moving objects). Then add your dynamic objects into the list. When a dynamic object is change you update the list. This way your only changing the list when somthing changes its depth.
As for making a "window" to see the player behind objects. this can be done by checking when we draw somthing. You need to make a bounding box or circle around the player. Simlpy the X,Y poition and and Radi. If the object your drawing is in fron of the play (ie: Obj.Depth < player.Depth) and Object.X-player.X < Radi and Object.Y-player.Y <radi then="" your="" dont="" draw="" the="" object.="" now="" this="" simple="" way="" will="" just="" not="" object="" at="" all="" which="" may="" cause="" some="" unwated="" visuals.="" in="" case="" we="" want="" to="" make="" a="" cusom="" function.="" if="" be="" is="" players="" bounding="" box="" instead="" of="" drawing="" it="" call="" our="" own="" cheack="" each="" pixel="" drawn="" see="" falls="" box.="" you="" can="" get="" clean="" circle="" around="" player.
ex:
px="" and="" py="" are="" point
void="" draw(object,px,py){
for="" (int="" x="0;" <="" object.width;="" x++){
="" for="" (y="0;" y="" object.height;="" y++{
="" (="" (math.abs((px+x)-(player.x))="">Radi) && (Math.Abs((pY+Y)-(player.Y))>Radi))
{
//Made up function Screen is your backbuffer or where your drawing to, then the X,Y location on the screen, then the source image pixel
SetPixel(Screen,pX+X,pY+Y,Object.image,X,Y);
}
}
}
}
|
|
|
|
|
I have been trying to run this program called mysqlbinlog.exe from my main c# application using the Process class(See example below). The way that mysqlbinlog functions is to read the first file in the command line and pipe the results to the second file.
This works fine when actually run from a command window on XP, but when I try to execute mysqlbinlog from the process class, mysqlbinlog runs but does not pipe the result to the second file. Can anybody see what I may be doing wrong here, or is there some trick that I do not know about. Any assistance or suggestions would be very much appreciated.
private void Form1_Load(object sender, System.EventArgs e)
{
//Declare and instantiate a new process component.
System.Diagnostics.Process process1;
process1= new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;
// Program file to run
string szProgFile = @"C:\Data\mysqlbinlog.exe";
// Cmd line arg to pipe results from rslog.001 to file1.txt
string strCmdLine = @"C:\Data\rslog.001 > C:\Data\file1.txt";
System.Diagnostics.Process.Start(szProgFile, strCmdLine);
process1.Close();
}
Craig
|
|
|
|
|
View Message Thread (2 replies)
Results 1 - 3 of 3
Piping data when using Process class
From: Tenacious
Date Posted: 5/3/2005 12:22:00 PM
I have been trying to run this program called mysqlbinlog.exe from my
main c# application using the Process class(See example below). The way
that mysqlbinlog functions is to read the first file in the command
line and pipe the results to the second file.
This works fine when actually run from a command window on XP, but when
I try to execute mysqlbinlog from the process class, mysqlbinlog runs
but does not pipe the result to the second file. Can anybody see what I
may be doing wrong here, or is there some trick that I do not know
about. Any assistance or suggestions would be very much appreciated.
private void Form1_Load(object sender, System.EventArgs e)
{
//Declare and instantiate a new process component.
System.Diagnostics.Process process1;
process1= new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;
// Program file to run
string szProgFile = @"C:\Data\mysqlbinlog.exe";
// Cmd line arg to pipe results from rslog.001 to file1.txt
string strCmdLine = @"C:\Data\rslog.001 > C:\Data\file1.txt";
System.Diagnostics.Process.Start(szProgFile, strCmdLine);
process1.Close();
}
I received this answer from a post I made on another web site and it appears to have fixed the problem:
The problem is that the output redirect, when run from the command line, is performed by the cmd shell. Try altering your program as follows
// Program file to run
string szProgFile = Environment.SystemDirectory + @"\cmd.exe";
// Cmd line arg to pipe results from rslog.001 to file1.txt
string strCmdLine = @"/c C:\Data\mysqlbinlog.exe C:\Data\rslog.001
C:\Data\file1.txt";
Craig
|
|
|
|
|
Hello Code Project Community!
Our Case:
The Customer has to unlock his application by passing a valid combination of a username and his serial number/key which we generated for him, using our own key generator.
Example:
Username: Jack Miller
Serial-#: 0954F43A-90C4AC01-F09951CF-9012387A
Currently we are doing a simple check: We encrypt the Username with a hardcoded salt and check if the result equals to the serial number (this is how we in fact generated it )
We dont need a perfect security here and we know everything can be bypassed but this is currently really enough.
But now we would like to keep additional information inside of the serial number, for example, a License type (would be enough if we have numbers for it from 1 = demo to 4 = enterprise) and also a date for evaluation versions.
So we would like the user to type in his Username and his Serial, and we could show him, that the Serial provided is a demo key, valid until 05.06.2005, for example.
There must be a good practice or strategy how to hide this information inside of the serial number, but we have no idea, because we have to keep the length of the serial number! Can you help?
Thanks in Advance!
Thomas
|
|
|
|
|
Hi!
From your description you're using a one-way encryption, where you only verify that a calculated hashkey matches the one in your serial number.
To be able to do so you don't need a reversible algorithm.
In order to decode the additional information you would need a reversible algorithm. I haven't found a way to decode information without placing the information on how to encode the same information in the same program. So it's always possible to encode modified information in a way that matches your algorithm. Your serial would be breakable quite easily.
The solution I've found to suit my needs best is to use a plain-text license file (XML) that contains a private key signature.
That way I can put arbitrary information into the license file and only have to give the public key in my program.
I can verify that the signature matches the license file's contents (i.e. the contents have not been tampered with) and don't have to worry that anybody can use the public key to compute a new signature.
Regards,
mav
|
|
|
|
|
Hello mav,
first of all thanks for your reply. i guess this is a not so bad attempt how to keep the key quite secure. but i am also missing the direct context to my problem...
Ok, i wrote my little encryption library and just keep the key hardcoded. i know that its easy to retrieve the key by disassembling or just debugging the libraries but currently that doesnt matter at all. So currently i am using the TripleDES symmetrical provider to encode the data. in contrast to the MD5 hash algorithm, where i always get very nice 32-bit strings, which are very usable for serial numbers, the encryption results in varying lengths of the encoded string as "ugly" Base64 Encoded Strings or Hex-Strings, which look better but are also longer.
ok now i could create my object which holds all the information needed, it could be xml-serialized then, and encrypted. but i get a very long encrypted string, much to long: We will send the most of our serials by Fax! I wonder, how i could keep the Serial Number still quite plain, maximum 32-40 Characters, and keep the information stored?
Regards,
Thomas
|
|
|
|
|
If you don't care about anybody finding out the algorithm, key and IV, then the symmetric algorithms in the framework are perfectly OK.
But the size of your encrypted information will be depending on the input data size. I tried encrypting a name followed by a separator character ('#') and a date and ended up with a Base64 encoded string of length 44 to 56.
I didn't manage to reduce the size of output by varying the key size.
Of course, Hex-strings are easier to type than Base64, but due to the limited alphabet are also longer.
You could work on the input data, though.
For example, instead of encrypting the whole name as it is you could just create a hashcode and encrypt this. Follow the hash code with a separator character and append the additional information you want to store.
That way you should be able to reduce the serial key reasonably.
Regards,
mav
|
|
|
|
|
ok, so far... thanks for the great support! * thumbs up *
|
|
|
|
|
Hello,
How do a strip Alpha-Numeric chars from a string?
Thank you.
|
|
|
|
|
I would recommend using regular expressions (System.Text.RegularExpressions ). In particular, look at System.Text.RegularExpressions.Regex.Replace method.
Your regular expression would look something like:
string myString = "Blessed! Happy! Fortunate! Are those who delight in the Lord."
string nonAlphaNumericString = Regex.Replace(myString, @"\w", string.Empty);
After executing the above regex, nonAlphaNumericString will == "! ! ! ."
As an alternative, you can use char.IsLetterOrDigit to determine if a character is a letter or digit, then you could construct a new string without letters or digits.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
Currently I'm facing problems displaying Unicode russian characters in RichTextBox controls in .NET 1.1 Windows Forms on a German Windows 2000 (Although normal TextBox controls correctly display russian characters).
When I use this code:
byte[] rawBytes = Encoding.Default.GetBytes( rawRtf );
using ( MemoryStream ms = new MemoryStream( rawBytes ) )
{
this.LoadFile( ms, RichTextBoxStreamType.RichText );
} The output looks like this: rtf-unicode-russian-01.gif (2.6 Kb)
And when I use this code:
byte[] rawBytes = Encoding.Unicode.GetBytes( rawRtf );
using ( MemoryStream ms = new MemoryStream( rawBytes ) )
{
this.LoadFile( ms, RichTextBoxStreamType.UnicodePlainText );
} The output looks like this: rtf-unicode-russian-02.gif (2.6 Kb)
So once it correctly displays the Unicode characters but literally outputs the RTF-formattings and one time it does the other way.
Question:
Can anyone explain whether it is possible to combine RTF text and Unicode characters at the same time?
Thanks
Uwe
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|