|
Is it possible to have a single instance of a class library?
I need a class library that returns the same object when 2 clients are using reflection to create it:
Assembly assembly=Assembly.LoadFrom("myclasslibrary.dll");
Type[] tp=assembly.GetTypes();
object app=Activator.CreateInstance(tp[0]);
Can "app" be the same when I use this code in 2 windows applications?
Thanks,
Bruno
|
|
|
|
|
There is a design pattern called a singleton, which is a class designed in such a way that only one instance of it can ever be created. I've never created a singleton in a dll that is called from multiple windows applications, but you may find that the pattern applies to your situation.
There is a site I came accross a few months ago, The Pattern Digest, http://patterndigest.com/. It covers most well known design patterns, including the singleton. I beleive it also has links to other resources. It may help you create the kind of singleton object you need.
|
|
|
|
|
Actually, I thought of this, but it doesn't go across boudaries.
|
|
|
|
|
Remoting might work well for this; the sample chapter for Ingo Rammer's book Advanced .NET Remoting
[^] might just be enough to get you going.
Good luck,
James
Sig code stolen from David Wulff
|
|
|
|
|
I'm developing a firewall log monitoring application in C#
with the .NET framework, and I can't figure out something.
I'm trying to do a reverse lookup on an IP address. I
don't mean reverse lookup to a DNS entry. I'm looking to
find out the computer-name behind the IP address.
The only thing I can find that's remotely related is:
Dns.GetHostByName() and Dns.GetHostByAddress().
However,these methods deal with IPHost objects, which only
contain DNS or IP information -- nothing about computer-
name.
Does anyone have any idea how to get a computer-name from
an IP address in my C#/.NET application? Is there anything
in .NET that will accomplish this? If so, what is it? If
not, what can I call outside of .NET that I can
incorporate into my application?
Thanks!
|
|
|
|
|
|
This is on a windows network? There is the WNet api in the PlatformSDK. You might be able to import functions from the windows networking DLL's to access windows networking information like computer names (wouldn't that be NetBIOS?).
|
|
|
|
|
No, this is not specific to a Windows network. I need to be able to get the "computer name" of any in-coming IP address to the firewall.
Basically, I want my app to be able to do what a NSLOOKUP call does. Get what I mean?
|
|
|
|
|
Yeah, makes sense. Is there an RFC or public spec for what NSLOOKUP does? I'd search the net for something and see if you can figure out the message format for NSLOOKUP messages.
|
|
|
|
|
If it's "across the wire" all you're going to get is the DNS reverse lookup. Machine names are not necessarily the same as the DNS name, and all TCP/IP w/DNS will give you is just that: The DNS name, which may or not be the machine name.
NetWkstaGetInfo() will only work on Windows machines (Pre Windows 2000 or Pre Windows 2000 compatible) where Anonymous access is allowed (a reeeeely reeeeeely reeely bad practice!)
Why do you need to know the actual machine name anyway? If there's suspicious behavior, you can trace the IP back. If it's illegal behavior, you can go deeper and give the authorities your firewall logs for the offense.
|
|
|
|
|
Hi All,
I'm trying to move colors for index 27 and beyond from the Colors enumeration to a new string[] array. The following moves them fine into the new array, and writes them out, but when the Databind occurs, it give me the following error.
Object reference not set to an instance of an object.
KnownColor enumColor = new KnownColor();
Array Colors = Enum.GetValues(enumColor.GetType());
string[] WebColors = new string[150];
for (int i=27; i< Colors.Length;i++)
{
WebColors[i-27] = Color.FromName(Colors.GetValue(i).ToString()).Name.ToString();
}
foreach (string s in WebColors)
{
Response.Write(s + " ");
}
cboColor.DataSource = WebColors;
cboColor.DataBind(); ERROR IS HAPPENING ON THIS LINE
I would be VERY thankful for any help.
Thanks,
Mike
|
|
|
|
|
I'm a CS student, and i need to write a console application which basically writes data packages read with a sniffer to a logfile and then sends data from a different logfile to a remote machine using TNS protocol over TCP. My app also has to communicate with a third party through another unique protocol over TCP.
As i never programmed with C# before, my question is if C# is suited for this kind of project or am i better off with C++ ?
|
|
|
|
|
You would be amazed how simple it is. See the System.Net.Sockets namespace, you have TcpClient and TcpServer class stuff waiting for you. As far as I can remember, there are articles on CP about this as well.
Good luck!
How low can you go ? (MS rant)
|
|
|
|
|
|
You can do async sockets on .NET. Several of my projects use the async functionality. Blocking sockets are mostly useless for the sorts of things I do.
.NET async sockets actually use IO completion ports internally, so its far better than CAsyncSocket. Oh, and they use delegates for notification, not windows messages.
|
|
|
|
|
hello
want to know some api's for opening and editing pdf file.
in c sharp.(c#).
Asim
|
|
|
|
|
Although the latest Acrobat 5 SDK[^] does not support explicitely .NET (interop come to the rescue at this point), you can generate PDF files with using C# code with this sourceforge library[^].
If instead of generating PDF files from scratch you intend to update existing PDF files, I would suggest to use interop, that is create a small wrapper around the Adobe SDK. If you are lucky, this wrapper will be automatically created for you (the Adobe SDK must be an explicit COM component).
How low can you go ? (MS rant)
|
|
|
|
|
Hi,
How to extract Mobile Phone number user who is watching WAP site using Mobile Internet Toolkit.
|
|
|
|
|
|
why?
just for it
|
|
|
|
|
I have already known solvation. The mobile phone number can be passed in http header. It is necassery to be set such option by cell phone company. (SMS Centrum has to be configured).
bye
|
|
|
|
|
HELLO SIR,
I WANT TO KNOW , HOW CAN I CONVERT MY XSL-FO DOCUMENT TO PDF DOCUMENT USING C#(SHARP). ALSO, FROM PDF TO XSL-FO.
I REALLY NEED THIS.
Asim
|
|
|
|
|
IS THE SHIFT LOCK BROKEN ON YOUR KEYBOARD ????
pdf is a proprietary format, AFAIK the only products that convert to and from it cost money. There is certainly no api call to do it. Isn't XSL-FO just formatting info, how would you convert a pdf document to *just* XML-FO ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Hmm...a little snappy are we, Christian?
Its entirely possible to convert from PDF to XSL-FO. It should also be possible to convert from XSL-FO to PDF, considering that PDF is a markup language like any other. You can open a PDF in wordpad or another text editor and see its markup. The only problem you would have is embedding images in a PDF. I have no idea how you would do that.
|
|
|
|
|
As for the comments about VB. I get really sick of hearing those. I've programmed for 17 years. My first language was Pascal, which at the time could have been considered the VB of languages. It wasn't elegant, it wasn't complicated, it was easy, simple, brainless. Without it I would probably never have learned to program as well as I do now. After a couple years programming in Pascal, I moved on to C++, which I have been using ever since, until the last 4 years. I've used VB, Perl, and Java (among others) along with C++ during those years. In the last year C# has replaced C++ as my primary programming language.
What makes me sick about programmers who think they are god is the way they look down on everyon else, especially newbies. VB aint the greatest language, but it does allow people to start learning. Without simple languages like Pascal and VB, a LOT of great programmers would likely never have even tried. What makes me even more disgusted is when programmers who think they are god move from just putting down VB programmers to putting down everyone. WHO GIVES A F*** IF SOMEONE USES CAPS!!! WHO GIVES A F*** IF SOMEONE USES VB!!! At least they are having fun, learning, doing something with their lives other than snapping at anyone who tries to achieve greater knowedge than they currently have, and possibly become more knowledgable than yourself.
Sorry for the rant, but it makes me sick how some programmers have to act like they know everything, and put every one else around them down to make themselves feel better. My last word on the subject...so flame away.
|
|
|
|