|
Its more of a preference for the programmer but security-wise and readability i agree it has to be put in a different form. I usualy do my queries in a different form, pass it to another dll for sorting, editing, etc then finally pass it to my win app or web app.
Hope that helps!
Kampai!!!
|
|
|
|
|
Hi, examine the following code.. for my puspose it works fine..
but, -How do I check 'myType' realy exists ???
public static object Construct(Type myType)
{
return System.Activator.CreateInstance(myType);
}
|
|
|
|
|
What do you mean? If you get that type as argument myType it does exist
If you mean something like System.Activator.CreateInstance("MyType",...); then it throws exception as described in MSDN[^]
You can use Assembly.GetType Method (String)[^] to determine if type is in assembly, it returns null if type wasn't found.
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
i was using the old system.web.mail classes.
and try to sent emails with net.mail, but i get an exception:
System.Net.Mail.SmtpFailedRecipientException was unhandled by user code
Message="Mailbox unavailable. The server response was: 5.7.1 Unable to relay for bla@bla.bla"
host property of SmtpClient must be set up! but what is default smpt host? is it "localhost"? i get an exception if i use it.
if i use this code it work for me (System.Web.Mail):
SmtpMail.SmtpServer = null;
SmtpMail.Send(mail);
because the name of the local SMTP server is used!!!!!!
WHAT NAME IS IT? how can i find it out?
i need the name to set the property Host of SmtpClient (System.Net.Mail).
thanks
thank u for ur advice
|
|
|
|
|
You have to specify SMTP-server, which you will use for sending mail...
I did following:
myClient = new SmtpClient(serverName, Convert.ToInt32(serverPort));
where serverName is IP-adress of SMTP-server.
--
Digitally yours, Bounz
|
|
|
|
|
Bounz wrote:
myClient = new SmtpClient(serverName, Convert.ToInt32(serverPort));
You may use IPAddress or the Dns Name of the server also. But the quicker trick would be CDOSys can be configured to relay to the local server and have the local server relay to a SmartHost in the network, which would do all relay, authorization checks etc to send the mail.
That way, our application is freed up from using a slow costly network communication resource through its process.
Vasudevan Deepak Kumar
Personal Web: http://www.lavanyadeepak.tk/
I Blog At: http://deepak.blogdrive.com/
|
|
|
|
|
|
How can i perfom case-NONsensitive replacing in string? Advice, please..
--
Digitally yours, Bounz
|
|
|
|
|
You could use a regular expression.
---
b { font-weight: normal; }
|
|
|
|
|
Give an example, please.
I want Replace() to find "thurman" in "Uma Thurman"... How can I implement this?
--
Digitally yours, Bounz
|
|
|
|
|
pattern like [Tt]hurman will work
Regex rx=new Regex("[Tt]est");
string strRep=rx.Replace("Test test testable Mohhahahah","XZXXX");
MessageBox.Show(strRep);
MCAD
|
|
|
|
|
thanks a lot to all..
i found answer:
i have to use
Regex rx = new Regex("(?i)WhatIWantToReplace"); <br />
string strRep = rx.Replace("TextInWhichReplace", "WithWhichReplace");
--
Digitally yours, Bounz
|
|
|
|
|
if you dont know the first character use
[\ws] which mean any character
so pattern would be like this [\ws]est
which will match test and best and so on
MCAD
|
|
|
|
|
Simply:
string result = Regex.Replace("Uma Thurman", "thurman", "whatever", RegexOptions.IgnoreCase);
---
b { font-weight: normal; }
|
|
|
|
|
Thanks a lot. I have learned a lot of new...
--
Digitally yours, Bounz
|
|
|
|
|
How can I get the actual directory of an assembly that has been placed into the GAC?
If I use the following code
System.Reflection.Assembly.GetExecutingAssembly().CodeBase
I get the GAC path back, e.g.
file:\c:\windows\assembly\gac\testGacLocation\1.0.0.0__826f0e5396cfccdecb
What I actually want it the real directory of the testGacLocation.dll file which is
C:\DirectoryA\DirectoryB\testGacLocation.dll
I cant hard code this as this directory may change but the DLL will always be gac'd.
The reason I need to do this is that there is text file in the testGacLocation.dll that the dll needs to read, when running an application that calls the read function in the dll it attempts to read from the application directory and not the dll directory.
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
|
Unfortunately that returns the directory of the executable directory
As an extended example I have the a DLL which is located here :
C:\Gactest\RefTestDll.dll
Which has the following code :
using System;
namespace RefTestDll
{
public class Dll
{
public string GetRefDirectory()
{
return System.Reflection.Assembly.GetEntryAssembly().CodeBase;
}
}
}
This dll is added to the GAC
I then have an application located here :
c:\GacTestApp\gactestapp.exe
Which uses the GAC reference to the DLL mentioned above using the following code:
using System;
namespace RefTestApp
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
RefTestDll.Dll d = new RefTestDll.Dll();
Console.WriteLine(d.GetRefDirectory());
}
}
}
The only directories I seem to be able to get back from the Reflection namespace is either the real GAC directory or the directory of the calling application.
|
|
|
|
|
It seems that I have found a solution, its nasty, its hacky, it probably wont be reliable but at the moment it seems to work.
When an assembly is entered into the GAC it is placed into the following directory :
c:\windows\assembly\GAC\[assembly name]\[assembly name]_[strong name]\
This directory also contains the following file :
__AssemblyInfo__.ini
This INI file contains a URL parameter which contains the path I need
using the following code:
private static string GetConfigPath(string configFileName)
{
string assemblyDirectory = string.Empty;
Assembly executingAssembly = Assembly.GetExecutingAssembly();
if( ( true == executingAssembly.GlobalAssemblyCache ))
{
IniReader iniReader = new IniReader(String.Format( @"{0}\{1}", System.IO.Path.GetDirectoryName(executingAssembly.Location), "__AssemblyInfo__.ini" ) );
assemblyDirectory = System.IO.Path.GetDirectoryName( iniReader.ReadString("AssemblyInfo", "URL", "") );
}
else
{
assemblyDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
}
return String.Format(@"{0}\{1}", assemblyDirectory, configFileName );
}
I can get the directory + the file name I specify
This function relies on an IniReader class which I obtained from:
http://www.mentalis.org
As mention above, this works but IMHO it hacking as hell, I am also not overly impressed that this sparkly .NET Framework thing uses INI files.
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
Hello gurus,
I'd like to know how it is possible to serialize the content of an ImageList class?
I wish to load and save the content of an ImageList from/to a file.
Can someone show me a code snipet please?
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
|
And how to do that???
Fred.
There is no spoon.
|
|
|
|
|
Hello...
Here is an example without exception handling:
// serialize
FileStream fs = new FileStream("C:\\imagelist.iml",FileMode.CreateNew);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs,il.ImageStream);
fs.Close();
// deserialize
FileStream fs = new FileStream("C:\\imagelist.iml",FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
il.ImageStream = (ImageListStreamer)bf.Deserialize(fs);
fs.Close();
|
|
|
|
|
After searching for a few "minutes", that's the way I have found in the MSDN.
It works fine.
Thanks
Fred.
There is no spoon.
|
|
|
|
|
Hi all,
any one can tell me how to maintain my form window on the desktop and not minimized when the user presses LWin (win logo) + D
thanks
kevin smoke
|
|
|
|