|
|
Hi,
is there any way in c# to load a windows control library dll dynamically?
the purpose is that i want to make a view of some datamodel replaceable without recompiling the whole program, i.e. that you can specify the dll to use in a config file and the program automatically loads the new library instead of the orginal one.
of course all these libraries are inherited from the same interface, but i don't know how the concrete implementations and DLLs will look like, yet...
(just like LoadLibrary / GetProcAddress but for c# user controls)
thx!
daniel.
|
|
|
|
|
Look at the Assembly class. Specifically, Assembly.Load, LoadFIle, and LoadFrom. Beware that LoadWithPartialName is deprecated in .NET 2.0.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
I just had to do the same in VB.net, so here is a sample code:
<br />
Dim GUIAssembly As System.Reflection.Assembly<br />
Dim GUIType As Type<br />
<br />
'Get access to GUI assembly<br />
GUIAssembly = System.Reflection.Assembly.LoadFrom("YourdllNameHere.dll")<br />
GUIType = GUIAssembly.GetType("Namespace.ClassName") 'ClassName is a class derived from "YourBaseControl" (see below).<br />
'Create User Interface Object<br />
Dim userInterfaceControl As YourBaseControl<br />
userInterfaceControl = Activator.CreateInstance(GUIType)<br />
StoreControl(userInterfaceControl)<br />
|
|
|
|
|
Hello gurus,
I'd like to know if there is a method somewhere that check if a give path as a String is valid or not?
Best regards.
There is no spoon.
|
|
|
|
|
Why can't you just put it in a try/catch block
try
{
OpenPath(string p);
}
catch(System.FileNotFoundException e)
{
MessageBox.Show("Incorrect path,try another ?");
}
catch(System.Exception e)
{
MessageBox.Show(e.Message);
}
|
|
|
|
|
If you mean something like a file path, you could use:
if(System.IO.Directory.Exists([path string]))<br />
{<br />
}
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Try the following to see if the string could be a valid path:
using System.IO;
string folderPath = @"c:\windows\test;;;;;invalid\";
if(folderPath.IndexOfAny(Path.InvalidPathCharacters) != -1)
{
}
Then use
Directory.Exists(folderPath);
to see if the path exists on disk.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
Thank you very much
Exactly what I needed
Best regards.
There is no spoon.
|
|
|
|
|
Like are their any dll's i can import that have some function to do this.
|
|
|
|
|
I’m trying to make a cast between two classes like this
AcadEntity entity;<br />
…<br />
Autodesk.AEC.Interop.ArchBase.AecWall wall = (AecWall)entity;
First time I run this an TypeLoadException is thrown. The second time I run these lines it works and the wall instance works perfect. How come it fails the first time?
The Exception message looks like this:
Could not load type Autodesk.AutoCAD.Interop.Common.IAcadObjectEvents from
assembly Autodesk.AEC.Interop.ArchBase, Version=4.5.202.0, Culture=neutral,
PublicKeyToken=d672471c03b2c408
_____________________________
...and justice for all
APe
|
|
|
|
|
Anyone know of a good Freeware/Source Code implementation of Secure FTP for either C#, C++, VB.NET, or Visual Basic ?
I don't have time to implement the STP protocol from something like Mentalis.org's ssl library...
.............................
There's nothing like the sound of incoming rifle and mortar rounds to cure the blues. No matter how down you are, you take an active and immediate interest in life.
Fiat justitia, et ruat cælum
|
|
|
|
|
|
Hello.
i want to make a project to take some references (*.dll) and to use the functions within, but to make the user to specify the location and the name, and set the namespace after i read the data from the user, until then the project doesn't know about that reference.
i wonder if a class exist and how can i use it to solve my problem.
Thank you.
regards,
metalsandman.
|
|
|
|
|
|
I have an application which required me to write some custom controls, so i placed them into dll files to make it easier to re-use. The problem is i want to deploy the application but i dont want my dll files exposed with the application, is there a way to hide the dll's or incorporate them in with the application executable similar to what Borland Builder does?
|
|
|
|
|
Hello all!
I am going to try to explain my problem as best as i can, please forgive my bad english.
Its like this, i am developing an application for handling scanned images and converting them to PDF. So far i have manged to do both of those things.
But i have a problem with saving the PDF file on a place of my choice.
As default the PDF file is saved in the bin folder. Now i know i can just write in the path where I want the file to be saved but I want to make it more dynamic.
I have simple text file containing the searchpath where the file should be saved, and i read it in to my application with the help of StreamReader. The searchpath is then read in to a string variable. Here is where the problem occurs. The string only returns null insted of the searchpath.
You can see my code below:
using System;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace doc2PDF
{
///
/// Summary description for pdf.
///
public class pdf
{
public pdf(string imageFileName)
{
string search ;
FileStream bFile = new FileStream("start.txt",FileMode.OpenOrCreate);
StreamReader test = new StreamReader(bFile);
search = test.ReadLine();
// step 1: creation of a document-object
Document document = new Document();
try
{
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter writer = PdfWriter.getInstance(document, new FileStream(search, FileMode.Create));// its here that i want the searchpath to appear(search,FileMode.Create)
writer.setEncryption(PdfWriter.STRENGTH128BITS,"elvir","elvir",PdfWriter.AllowCopy);
// step 3: we open the document
document.Open();
// step 4: we add content to the document
PdfContentByte cb = writer.DirectContent;
Image image = Image.getInstance(new System.Drawing.Bitmap(imageFileName), System.Drawing.Imaging.ImageFormat.Png);
image.setAbsolutePosition(0,0);
image.Alignment = Image.MIDDLE;
image.scaleAbsolute(600, 800);
cb.addImage(image);
}
catch(DocumentException de)
{
Console.WriteLine(de.Message);
}
catch(IOException ioe)
{
Console.WriteLine(ioe.Message);
}
// step 5: we close the document
test.Close();
document.Close();
}
}
}
iTextsharp is the PDFlibrary that I use to make PDF files.
Any help is appriciated.
Thanks in advance
|
|
|
|
|
It looks like the line:
FileStream bFile = new FileStream ("start.txt",FileMode.OpenOrCreate);
is creating a new file rather than opening your "start.txt" file. Try specifying the path to start.txt like this:
FileStream bFile = new FileStream ("c:\\start.txt",FileMode.OpenOrCreate);
Then place "start.txt" in the root of drive C.
Hope that helps.
|
|
|
|
|
Hello
I'm trying to make a Dns query against ordb.org (a database contaning smtp servers that are classified as open relays).
I know that ordb.org wants the ipaddress for the smtp server with the octets reversed but that's not the problem.
I've been trying to construct a udp packet to send the information to the database but I can't get it right. I don't recieve an answer and i'm unsure if I'm attacking the problem from the right angle so to speak. Below is a rough code example on how I've been trying solve the problem.
/*Send question*/
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
byte[] data = Encoding.ASCII.GetBytes(ReversedSMTPIP);
IPAddress addr = Dns.GetHostByName("relays.ordb.org").AddressList[0];
IPEndPoint dest = new IPEndPoint(addr,53);
client.SendTo(data,(EndPoint)dest);
/*Recieve answer*/
byte[] msg = new byte [32*1024];
IPEndPoint iend = new IPEndPoint(IPAddress.Any,0);
EndPoint end = (EndPoint)iend;
int lenght = client.ReceiveFrom(msg,ref end);
string answer = Encoding.ASCII.GetString(msg);
Below is the information from ordb.org FAQ which I'm having trouble understanding correctly.
The simplest way to get started using the ORDB to protect your mail relay against theft of service by spammers, is to arrange for it to make a DNS query agains relays.ordb.org whenever you receive an incoming mail message from a host whose relaying status you do not know.
The theory of operation is simple. Given a host address in its dotted-quad form, reverse the octets and check for the existence of an ``A RR'' at that node under the relays.ordb.org node. So if you get an SMTP session from [192.89.123.5] you would check for the existence of:
5.123.89.192.relays.ordb.org. IN A 127.0.0.2
We chose to use an ``A RR'' because that's what most MTA's can use to filter incoming connections. The choice of [127.0.0.2] as the target address was arbitary but will not change. As it happens, we supply a bogus ORDB entry for [127.0.0.2] so that mail transport developers have something to test against.
I'm on the right track here?
Any help at all would be greatly appriciated.
Best Regards
Kristofer
|
|
|
|
|
I think you need a send a full DNS query, instead of just the reversed SMTP IP. You need to form an actual DNS query and in the place of the domain name, use 5.123.89.192.relays.ordb.org or whatever.
The DNS query has a definite structure, which you can see here[^]
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Ok I read the RFC - 1035 and parts of RFC - 1034. I now understand it much better but how do I construct the packet?
As I understand it I have to create my own header and subparts of the query but how do I "type" the information and how do I delimit it?
Thanks for the help!
Regards
Kristofer
|
|
|
|
|
Hi,
im trying to capture the position of the mouse from the mouse move event and changing some properties. But the mouse move event doesnt seem to be fast enough to capture the movements immediately and change the properties accordingly!! Can anybody help regarding this?
Thanks and Regards,
Rajesh
|
|
|
|
|
In the mouse move event:
private void _MouseMove(sender,e)
{
Point p = Control.MousePosition;
//and then try to apply what you want according to the value of this point like:
this.Location = p;
}
|
|
|
|
|
Hi all
Please advice me how i can to change keyboard layout programatically in c#.
Thank.
|
|
|
|
|
Hello,
I have a data class in my Web Service server. Its name is User.
When I include this web service to the client and name it "WSA" the User class will be WSA.User.
the problem is when I serialize a User instance in client its type will be WSA.User and I can not deserialize it to a User instance in server. the types will be different.
What can I do?
|
|
|
|