|
Why not make two separate dll files, one is for command line and the other a service. Then all the exe has to do is determine which one to run, then invoke the proper dll. It meets your customer's spec of only having one exe, while making implementing it easy on you.
|
|
|
|
|
Hi guys!
I'm trying to install a printer driver via WMI and C#
I can invoke the method but always get a "87" (invalid parameter) as return value.
But I have absolutly no idea what could be wrong with the parameter (I suppose that it's the "DriverInfo" param).
<br />
ManagementClass classInstance = new ManagementClass("root\\CIMV2", "Win32_PrinterDriver", null);<br />
<br />
ManagementObject driverInfo = classInstance.CreateInstance();<br />
driverInfo["Name"] = "Adobe Postscript 5";<br />
driverInfo["Version"] = "3";<br />
driverInfo["SupportedPlatform"] = "Windows NT x86";<br />
driverInfo["DataFile"] = "C:\\Temp\\adobe\\DEFPRTR2.PPD";<br />
driverInfo["ConfigFile"] = "C:\\Temp\\adobe\\PS5UI.DLL";<br />
driverInfo["DriverPath"] = "C:\\Temp\\adobe\\PSCRIPT5.DLL";<br />
driverInfo["HelpFile"] = "C:\\Temp\\adobe\\PSCRIPT.HLP";<br />
string[] depfiles = {"C:\\Temp\\adobe\\PSCRIPT.NTF", "C:\\Temp\\adobe\\PSCRPTFE.NTF"};<br />
driverInfo["DependentFiles"] = depfiles;<br />
<br />
ManagementBaseObject inParams = classInstance.GetMethodParameters("AddPrinterDriver");<br />
<br />
inParams["DriverInfo"] = driverInfo;<br />
<br />
ManagementBaseObject outParams = classInstance.InvokeMethod("AddPrinterDriver", inParams, null);<br />
<br />
Console.WriteLine("Out parameters:");<br />
Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);<br />
Perhaps someone can help me?
|
|
|
|
|
I'm working on some peer-to-peer stuff and I need to make this service available to those behind routers. Two things need to be accomplished:
1. Detect whether or not the user is behind a router.
2. If the user is behind a router, forward port X to the user's network IP.
I've seen this done using COM and C, but I can't translate into C#.
Thanks!
|
|
|
|
|
UPnP is very handy for this. Having a quick search around I came across this code:
http://www.thescripts.com/forum/thread431643.html[^]
if you pick your way through that and understand it you can probably use it as the basis for any other UPnP stuff you need (although that might cover it all).
|
|
|
|
|
in the sql server numeric datatype , the dimensions are of the following form
precision
Scale
I know the meaning of presision.can somebody explain te meaning of scale.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
"p (precision)
Specifies the maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision. The maximum precision is 38. The default precision is 18.
s (scale)
Specifies the maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through p. Scale can be specified only if precision is specified. The default scale is 0; therefore, 0 <= s <= p. Maximum storage sizes vary, based on the precision."
MSDN Library: decimal and numeric[^]
---
single minded; short sighted; long gone;
|
|
|
|
|
I'm using Microsofts implementation of ripemd 160, as declared in System.Security.Cryptography. It produces different results when run on Windows XP and server 2003.
I needed to test an application via RDP on a 2003 machine and noticed that the hashes produced was not coherent with the ones I got when using windows XP.
Is this a known bug or am I doing something wrong? Please let me know if you need additional information.
/martin
|
|
|
|
|
Bumping the thread and correcting myself.
After some serious tracing I have concluded that the problem is regarding the byte order in win2003. The problem appears when translating the byte array from the hash to a integer. The hashbytes correspond to eachother.
I cant seem to find a workaround for this problem. Does anybody have one?
|
|
|
|
|
Any one help me that , I have 2 files i.e File1 & File2.
My objective is to append all the contents of File2 into the preexisting File1.
With Regards
Tapan
|
|
|
|
|
File.AppendAllText("File1",File.ReadAllText("File2"));
If your files are at different locations, you will need to specify full path
|
|
|
|
|
I've been trying to keep information of individuals logged on to my website so now i dont know how to do that cause on each and every page load i loose the values which were stored on my variable so how do i overcome such problem.Cause i have masterpage with login section and subpages loading on master page will use those values to check user's rights to the system when ever i load a page.
mafunwat@yahoo.com
Department of IT
DUT
|
|
|
|
|
u can put the variables in session object.
rahul
|
|
|
|
|
I created Check Boxes in Property Grid using UITypeEditor. I also need to create Property items dynamically , so I used Custom Property creation using PropertyDescriptor class adn created properties using CreateProoperty.
The problem is: After using CustomProperty descriptor I am no longer able to see checkboxes or listBoxes created using UIType Editor .
Any one have faced this problem before ? How to use UITypeEditor and PropertyDescriptor together in my class and does not lose the UITypeEditor visual (checkboxes, Listboxes)
Cheers,
Rajan
Rajan
|
|
|
|
|
Typically the editor is defined as an attribute on the property. Since you are dynamically adding properties, then you would either need to manually create and add the attribute to the PropertyDescriptor, or simply override the GetEditor[^] method.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hello.
I'm having a bit of problem with a service written in C#. It starts just fine under Windows XP and Vista. But when i try to run it under Windows 2000 (server) the service just hangs on startup.
The service is set to run as LocalSystem, and the only thing it does in the OnStart()-method is to spawn a worker-thread that is supposed to do all work. However the OnStart()-method doesnt even trigger. I've added a couple of trace-points using EventLog.WriteEntry() to see how far the service comes when its starting.
Seem to hang on the call to ServiceBase.Run(servicesToRun); Sometimes the EventLog states that the service hung on startup, but no further info is provided (and the service can still bee seen as "starting" in the service manager).
Does someone here know whats going on? And how to fix it?
|
|
|
|
|
Have you tried running it as a console app to see if it's the code or if it's because it's a service?
9 times out of 10 I find it is the fact that it's running as a service :/ but atleast then you'll know for sure.
Theres always the old fall back of putting
MessageBox.Show("1");
//line of code
MessageBox.Show("2");
//line of code
MessageBox.Show("3");
then setting the service to allow interaction with the desktop, this will allow you identify the exact line of failiure.
Another option is putting in Thread.Sleep(10000); somewhere near the start of the service ... this gives you a bit of time to attach to the process so you can properly debug it. Of course it also eats up part of your 30 second timeout before the service will be reported as failed.
|
|
|
|
|
Havent tried to run it as a normal application yet. Will do that later.
The good old trick of constant output is what I've been trying. Just before the call to ServiceBase.Run(servicesToRun); I'm callin EventLog.WriteEvent() and the first thing that is done in the OnStart()-handler is to write another entry in the event log.. That second entry never appears in the log however... But just to be sure, I will try your example with letting the application interact with the desktop.
Using remote debugging reveals tow threads, one without a traceable stack and one thread being stuck on the ServiceBase.Run(servicesToRun)-call.
|
|
|
|
|
Hello All,
Iam a new to this forum.I want some help.
Iam having an .aspx page in that iam having many listbox control.Selection mode is single.Iam binding data to these list box control from the data base while page loading.This is fine no problem.Now i want to store the selected values in to another table on a button click event.but iam getting selected itmes as null.
Please help on this.
i want to join this group
|
|
|
|
|
add the following framework base class
Microsoft.Visual basic.Compatibility.vb6
and use the functions
Support.GetItemData()
Support.SetItemData()
Do u know something the solution about the problem i mentioned just below ur query
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
i want to show the percentage of the records in pie charts and bar charts using the crystal reports.Can somebody please provide any useful link.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Hi,
As per my knowledge all the 7 blocks in the Microsoft Enterprise Library(Pattern & Practices) require atleast a configuration(.config) file.
But while developing a .dll i.e an assembly without using a .config file can I use Enterprise Library. if not for all then for logging or exception handling referencing the dlls from the enterprise Library.....
Required an expert opinion...
Thanks
Sangram
(A battle with self)
Life is simple, we are the ones makes the living difficult
|
|
|
|
|
Would someone please give me a good book I can learn C# 2005 from? I am not new to programming, but kind of new to C#.
Thanks.
|
|
|
|
|
|
Sams Teach Yourself Visual Studio .NET 2003 in 21 days[^]
Their may be a more up to date one, but this is the one that I use.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
I have these line of codes :
try
{
string fromDir = file.Substring(0, file.LastIndexOf("\\"));
System.IO.Directory.SetCurrentDirectory(fromDir);
if (!File.Exists(fileToZip))
{
throw new FileNotFoundException("The specified file " + fileToZip + " could not be found. Zipping aborderd");
}
FileStream StreamToZip = new FileStream(fileToZip, FileMode.Open, FileAccess.ReadWrite);
FileStream ZipFile = File.Create(zippedFile);
ZipOutputStream ZipStream = new ZipOutputStream(ZipFile);
ZipEntry ZipEntry = new ZipEntry(fileToZip.Substring(fileToZip.LastIndexOf("\\") + 1));
ZipStream.PutNextEntry(ZipEntry);
ZipStream.SetLevel(CompressionLevel);
if (password != null && !password.Equals(string.Empty))
ZipStream.Password = password;
byte[] buffer = new byte[BlockSize];
System.Int32 size = StreamToZip.Read(buffer, 0, buffer.Length);
ZipStream.Write(buffer, 0, size);
try
{
while (size < StreamToZip.Length)
{
int sizeRead = StreamToZip.Read(buffer, 0, buffer.Length);
ZipStream.Write(buffer, 0, sizeRead);
size += sizeRead;
}
}
catch (System.Exception ex)
{
throw ex;
}
ZipStream.Finish();
ZipStream.Close();
StreamToZip.Close();
}
catch (Exception ex)
{
throw ex;
}
The error occurs on this line
FileStream ZipFile = File.Create(zippedFile);
how am i going to resolve it? thanks
|
|
|
|