|
Hello,
I did this, and the program still can't find the dll.
Thanks
Peterson
|
|
|
|
|
Peterson Luiz,
Why do you want to do this anyways?, Is this dll used over multiple programs?, eg is a lib dll?
Can it be in the same program directory but in another folder?
eg: C:\YourProgy\DllFolder\name.dll ?
Also, when you say it doesn't work when putting it in the system32 folder. Have you built the program and then installed it on a another machine? or just running it in debug?
Regards,
Gareth.
|
|
|
|
|
Hi,
- Yes, I whant to do this because there are other programs using this dll.
- No, I needeed the dll in program files\my folder...
- Yes, I have built the program and tested in other computer.
Any ideas??
Thanks
Peterson
|
|
|
|
|
.NET will look for an assembly (your shared .NET dll) in the same directory as the executable or if it's not found there then the Global Assembly Cache (GAC). So, to share that DLL you'll either have to copy to both EXE directories or install it to the GAC.
|
|
|
|
|
I'm currently writing a little password-manager to store my passwords and the associated data my way.
Of course I would prefer the stored data not to be plainly readable to anyone, so I thought of encrypting it.
However, I couldn't really find any way of doing it elegantly.
1. I want to enter a password of my choice to encrypt it. Rijndael and others always need a key of a specific length, so the choice of passwords is limited to the accepted length .
2. Some methods I found need an input file and an output file. This is not particularly elegant, since one has to erase the input file (encryption) or the output file (decryption) afterwards, in order not to have a plainly readable version. Other methods encrypt a string, while I am serializing objects in a stream.
Here is what I have so far (without encryption):
Saving:
<br />
private void SaveFile(string path) {<br />
Stream stream = null;<br />
try {<br />
stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);<br />
<br />
MemoryStream memoryStream = new MemoryStream();<br />
GZipStream compressedStream = new GZipStream(stream, CompressionMode.Compress);<br />
IFormatter formatter = new BinaryFormatter();<br />
formatter.Serialize(memoryStream, ((PasswordList)ActiveMdiChild).List);<br />
memoryStream.WriteTo(compressedStream);<br />
<br />
compressedStream.Flush();<br />
compressedStream.Close();<br />
} catch (Exception r) {<br />
throw new ApplicationException("File could not be created " + r);<br />
} finally { if (null != stream) stream.Close(); }<br />
}<br />
Opening:
<br />
private void openToolStripMenuItem_Click(object sender, EventArgs e) {<br />
OpenFileDialog openFile = new OpenFileDialog();<br />
openFile.Title = "Open";<br />
openFile.InitialDirectory = Environment.CurrentDirectory;<br />
<br />
if (openFile.ShowDialog() == DialogResult.OK) {<br />
Stream stream = null;<br />
try {<br />
IFormatter formatter = new BinaryFormatter();<br />
stream = new FileStream(openFile.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);<br />
GZipStream compressedStream = new GZipStream(stream, CompressionMode.Decompress);<br />
PasswordList newList = new PasswordList(this, (List<entry>)formatter.Deserialize(compressedStream));<br />
compressedStream.Close();<br />
<br />
newList.MdiParent = this;<br />
newList.filename = openFile.FileName;<br />
InitializeNewList(newList);<br />
} catch (Exception r) {<br />
throw new ApplicationException("File could not be opened" + r, r);<br />
} finally { if (null != stream) stream.Close(); }<br />
}<br />
}<br />
</entry>
Does anyone know an elegant way (not writing the file, encrypting it and then throwing away the original file) to include encryption and decryption with an arbitrary password (that I will get through a dialog) in that code.
|
|
|
|
|
|
I found that article too. But the problems I described are not solved by this method.
1. The method encrypts a string and decrypts to a string. I don't have a string! (Or I would first have to encrypt all the strings before serializing! )
2. The key for Rijndael has to be of a fixed length (128, 192, or 256 bits), so I can't use a password of my choice.
|
|
|
|
|
Some encryption methods always give a fixed length (I'm thinking of PHP's MD5 function). You could maybe encrypt the password you choose using something like that and then use that to do the Rijndael thing.
There's quite a few examples of MD5 PHP style encryption if you google but (from experience) check them carefully as I've found with some they don't always work properly. I remember one I tried that didn't give a leading Hex zero for bytes less than 16 (decimal) so what should have been
0A0A0A0A0A0A0A0A came out as AAAAAAAA - not fixed length.
I haven't tried it but this[^] one looks ok.
|
|
|
|
|
As indicated by a previous user, all you need to do is intantiate the cryptostream class on top of your GZipStream, then use the resulting stream to read/write the serialized data. As far as the password goes, I would try to add some random characters (salt) to your passphrase, then take the SHA256 hash of that new string and use the hash as the key to create a new Rijandael cryptostream which would be used as previously stated. Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hello everyone.
Some time ago, I was working with Hashtables when I found a limitation: as an example I will use the following:
Hashtable countryInfo = new HashTable();
countryInfo.Add("Canada", "Ottawa");
countryInfo.Add("UK", "London");
countryInfo.Add("France", "Paris");
...
This is great: given the country France, I can find out that it's capital is Paris:
string capital = countryInfo["France"] What I can't do is find out is what country is Paris the capital of (without looping through the table).
So I created MultiHashTable which, instead of holding key,value pairs, holds key,key,key... sets. I can now do things like:
MultiHashTable countryInfo = new MultiHashTable("Country", "Capital", MultiHashTable.Unkeyed("Language"));
countryInfo.Add("Canada", "Ottawa", "English");
countryInfo.Add("UK", "London", "English");
countryInfo.Add("France", "Paris", "French");
(note: the "Language" table is "Unkeyed" because it must hold duplicate entries for Canada and UK).
Now I can find out what country has Paris as it's capital:
capital = countryInfo.GetItem("Country", "Capital", "Paris"); and other things that I needed to do.
My question is this - did I re-invent the wheel? I keep discovering all kinds of stuff already built into C# and I can't help but think that this sort of thing is already in there somewhere.
I won't consider my time wasted if it is - creating MultiHashTable was a great learning experience - I just want to know if at some time in the future someone is going to say "well why don't you just use System.Collections.SuperCrossRef like everybody else?"
Clive Pottinger
Victoria, BC
modified on Wednesday, January 23, 2008 1:42:53 PM
|
|
|
|
|
Iam not sure what version you are working on, i think this can be done with Dictionary(.net 2.0), Please take a look at it.
Thanks
Srini
|
|
|
|
|
I need a quick tutorial on how to build a wpf app without any IDE. I want to know this because Visual Studio generates a bunch of code and it attempts to hide most of it and the designer code just looks like a mess. I want to know the simplest COMPLETE boiler plate code nessecary to display a window with a button on it using XAML and C# using notepad and the command-line. I googled around but I cant seem to find what I want.
Word, write letters and sh*t yo.
It takes 46 muscles to frown but only 4 to flip 'em the bird.
Friendship is like peeing on yourself: everyone can see it, but only you get the warm feeling that it brings.
The greatest pleasure in life is doing what people say you cannot do.
Everyone needs believe in something. I believe I'll have another beer.
|
|
|
|
|
CataclysmicQuantum wrote: I googled around but I cant seem to find what I want.
Yeah that was tough[^]
two clicks away to this[^]
Building a WPF Application (WPF)
Windows Presentation Foundation (WPF) applications can be built as .NET Framework executables (.exe), libraries (.dll), or a combination of both types of assemblies. This topic initially shows how to build simple WPF applications from the command prompt, before showing how WPF leverages the extensibility of Microsoft build engine (MSBuild) to build more complex applications. This topic finishes by providing an in-depth discussion of the key steps in the MSBuild build process.
led mike
|
|
|
|
|
I had found that when I was looking, thats not quite what I am looking for.
I know how to use the command-line and all that. I just need a very simple tutorial that says something like "Create .cs file with class Program with Main(), add this code to it, create .xaml file...." Notice the 1 star rating on that MSDN article. I'm not the only one who doesn't liek it.
Word, write letters and sh*t yo.
It takes 46 muscles to frown but only 4 to flip 'em the bird.
Friendship is like peeing on yourself: everyone can see it, but only you get the warm feeling that it brings.
The greatest pleasure in life is doing what people say you cannot do.
Everyone needs believe in something. I believe I'll have another beer.
|
|
|
|
|
|
Thats perfect, thanks.
Word, write letters and sh*t yo.
It takes 46 muscles to frown but only 4 to flip 'em the bird.
Friendship is like peeing on yourself: everyone can see it, but only you get the warm feeling that it brings.
The greatest pleasure in life is doing what people say you cannot do.
Everyone needs believe in something. I believe I'll have another beer.
|
|
|
|
|
I'd help you, but the drug rehab is shut right now.
WPF - Imagineers Wanted
Follow your nose using DoubleAnimationUsingPath
|
|
|
|
|
Is it possible to get the name of the DLL your code is executing in?
For instance, I have MyLib.DLL that contains the class "MyClass". Inside MyClass, I have a function that needs to know the name of the DLL it's running in.
How does one accomplish that in .Net?
It's done like this:
Module mod = Assembly.GetExecutingAssembly().GetModules()[0];
string name = mod.Name;
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Wednesday, January 23, 2008 11:32:24 AM
|
|
|
|
|
Assembly.GetExecutingAssembly().FullName will get the name of the assembly. Assembly.GetExecutingAssembly().Location will get the location of the assembly.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Hello!
I'm stuck with the following problem:
I've created a base class
<br />
public abstract class GenericFieldBase<><br />
from which I derived a number of child classes such as
<br />
public class StringField : GenericFieldBase<string>;<br />
public class IntegerField : GenericFieldBase<int>;<br />
public class DoubleField : GenericFieldBase<double>;<br />
public class DateTimeField : GenericFieldBase<DateTime>;<br />
Question is: what type should a variable have to contain either of these derived classes?
<br />
GenericFieldBase<...> var;<br />
<br />
var = new StringField();<br />
var = new DoubleField();<br />
var = new DateTimeField();<br />
thank you very much!!
-- edit: now alle brackets should be in place.
modified on Wednesday, January 23, 2008 10:45:57 AM
|
|
|
|
|
A variable of type GenericFieldBase can contain an instance of any class derived from GenericFieldBase.
|
|
|
|
|
I'm not quite shure whether I understand corretly.
For 'normal' types I know that typing
<br />
BaseClass var = new DerivedFromBaseClass();<br />
is possible.
But when generics come into play I normally have to give a type argument between < > brackets.
Back to the first example: I could write
<br />
GenericFieldBase<string> var_string;<br />
GenericFieldBase<double> var_double;<br />
GenericFieldBase<datetime> var_datetime;<br />
<br />
var_string = new StringField(); <br />
var_double = new DoubleField();<br />
var_datetime = new DateTimeField();<br />
But what I really want is a variable of type GenericBaseField which can hold a derived class of any generic type. But simply typing
<br />
GenericFieldBase var;<br />
var = new StringField()<br />
gives compile error:
"Using the generic type 'generic type' requires 'number' type arguments "
-- edit: corrected missing brackets
modified on Wednesday, January 23, 2008 10:51:27 AM
|
|
|
|
|
The syntax you gave for GenericFieldBase looked non-generic because there were no angle brackets <> in the declaration. A specific example would clarify your situation.
If C# won't let you derive a class from a generic, you can define a non-generic base class that has a generic member. This may give you the flexibility you need because the derived classes can then use the generic member in different ways.
As a last resort, you can use type "object", which can hold anything. (Sort of like a void pointer in C++).
|
|
|
|
|
Unless I'm missing something in your post - GenericFieldBase isn't actually a generic class. Therefore, you could simply do this:
GenericFieldBase var = new StringField();
|
|
|
|
|
It appears not all your '<' and '>' characters got posted correctly. See if you can edit your post so they are all visble.
led mike
|
|
|
|