|
I can get a collection of system variables, and the collection of controls my form has in it. But, is there a method to get the collection of class variables, and possibly local variables to a function? This is for error-handling purposes, so as much information about my runtime that I can get, the better. This is a windows app, not asp. Thanks!
|
|
|
|
|
DougW48 wrote:
This is for error-handling purposes, so as much information about my runtime that I can get, the better.
It sounds like you are trying to break encapsulation which would really muddy and complicate the design of your application.
If an unexpected error condition arises you should throw an exception. If you need to you should create an exception class and design it so that it can be loaded with the error information so that the error handler (the catch block) can see the necessary information. However you should think carefully about whether you actually need the information or if it is just a quick solution now that will muddle things in the future.
Cada uno es artifice de su ventura
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
It is possible to get values of class level variables using reflection, but I don't think it is possible to write generic code to get values of local variables.
Regards
Senthil
My Blog
|
|
|
|
|
How do I make a service that will not appear in the process list when it is done?
Specifically, I want to have an invisible service that would restrict all traffic on a computer. And no, this is not being done with malicious intent, but it does have to be invisible for other reasons.
Cheers,
Jim
|
|
|
|
|
|
You can hide processes from task manager but as far as I know you cannot hide a service from the services list.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
|
That might be a way to do it and also svchost.exe I guess. I'm talking about "hiding" of course. I never needed it but a friend of mine was able to do it in C++ (I remember using some APIs) But what I know is, it is not legal because you'll have to reconfigure some system settings and the user won't be able to see it in the list so won't have the chance to end the app... Also, another way is registering the app as a service so it won't be in the process list but will be visible to advanced users in the services. If I remember right, it was something like this "RegisterServiceProcess lib "kernel32" (lngProcessID As Long) As Long" via WScript..
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Colin Angus Mackay wrote:
The only way I could think of was with dllhost
Well , Colin , I'd be pleased if you tell me how you can hide it in this way.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
|
hi all, am new to C# programming and i got a little problem
am having some text boxes in my form, and i want the mouse cursor to move automatically to the next textBox when the user inputs data in the preceding textBox. Just like when you enter the WinXP serial, u don't have to click 'TAB' to move to next TextBox.
thnx for ur help.
|
|
|
|
|
You can subscribe to the KeyPress event and check if the textbox has got the required number of characters. If it has, you can move focus to the next textbox. Something like
public void KeyPress_textBox1(...)
{
if (textBox1.TextLength == 5)
{
textBox2.SetFocus();
}
}
Regards
Senthil
My Blog
|
|
|
|
|
thnx for ur help,
one more thing, could I determine which data type could be entered in the text box, i.e. if the user entered "floating" no. for example it doesn't move the cursor. The user should enter "integer" for the cursor to move to the nexr text box.
|
|
|
|
|
You can use the Parse method on the Int32 class. Something like
<br />
...<br />
if (textBox1.Length == 5)<br />
try<br />
{<br />
Int32.Parse(textBox.Text);<br />
textBox2.Focus();<br />
}<br />
catch(Exception)
{<br />
}<br />
}<br />
Regards
Senthil
My Blog
|
|
|
|
|
Hello,
I'm writing an application that has to have a de/compressing algorithm used to store data. The algorithm I want to use is the LZNT and its functions are exported in NtDll.Dll as far as an unofficial documentation says. I was able to find the 3 functions' syntax, but I can't get them to work. Here they are (DLLImport info stripped):
public static extern void RtlCompressBuffer(
ulong CompressionFormat,
void *SourceBuffer,
ulong SourceBufferLength,
out IntPtr DestinationBuffer,
ulong *DestinationBufferLength,
ulong Unknown,
out ulong *pDestinationSize,
void *WorkspaceBuffer );
public static extern IntPtr RtlDecompressBuffer(
out IntPtr DestinationBuffer,
ulong DestinationBufferLength,
IntPtr SourceBuffer,
ulong SourceBufferLength,
ulong *pDestinationSize );
public static extern IntPtr RtlGetCompressionWorkSpaceSize(
ulong CompressionFormat,
out ulong *pNeededBufferSize,
out ulong *pUnknown );
Please correct me if I'm wrong with them, and I'd like to see any sample code which I can use for manipulating data.
Thank you in advance, and best regards,
Stan
P.S. here is the code I tried
Stream fs = new FileStream("input.exe", FileMode.Open); //input.exe is a test file
byte[] DataIn = new byte[fs.Length];
fs.Read(DataIn, 0, (int)fs.Length);
fs.Close();
IntPtr p_DataOut;
ulong *pDS;
byte* bt = stackalloc byte[DataIn.Length];
fixed(byte *p_DataIn = DataIn)
{
RtlCompressBuffer(0x0002 /*LZNT*/, p_DataIn, (ulong)DataIn.Length, out p_DataOut, (ulong*)DataIn.Length, 0x1000, out pDS, bt);
}
I get a NullReferenceException when executing RtlCompressBuffer, but as far as I saw, none of the parameters is null, except the ones with 'out' modifiers
|
|
|
|
|
Do NOT use pointers in managed code (unsafe code). There is no reason to use this, though there are acceptable reasons for performance like when manipulating pixels.
out ulong is already serving the role of a pointer, too. out ulong* with an unsafe context would actually be more like unsigned long** in native code.
You should read Marshaling Data with Platform Invoke[^] in the .NET Framework SDK to gain a better understanding of how native types translate to managed types. You can also visit http://pinvoke.net[^] for signatures to many common APIs.
You should also refrain from using undocumented APIs because they can be changed without warning, not to mention that they are not officially documented by Microsoft. There are better ways to gain compression in .NET, including class libraries that implement compression without resorting to P/Invoke, which means your applications that use such libraries are more likely to be portable to other platforms.
One popular compression library is SharpZipLib[^] but you can search for many more.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
how can I change the column order in DataGrid,the dataGrid isnt showing coumns in order i specifed argument in my Class Constructor,currenly it shows column in following order:
UserField,SiteName,ConnStr,cID,ipAddr
though cID is supposed to come first
i using ArrayList as a datasource for DataGrid
i am adding objects in array by doing this:
this.arrPref.Add(new cPreferences(intgr1,str3,str1,str2,str4));
where cPreference class is defined like this:
public class cPreferences
{
protected int cid=0;
protected string site_name="";
protected string connection="";
protected string user_field="";
protected string ip_addr="";
public cPreferences(int c_id,string usrfld,string sname,string cs,string ipAdrr)
{
cid=c_id;
site_name=sname;
connection=cs;
user_field=usrfld;
ip_addr=ipAdrr;
}
//Set or Get Property of CID
public int cID
{
get
{
return cid;
}
set
{
cid=value;
}
}
//set-get the Property of Site Name
public string SiteName
{
get
{
return site_name;
}
set
{
site_name=value;
}
}
//set-get property of Connection String
public string ConnStr
{
get
{
return connection;
}
set
{
connection=value;
}
}
//set-get property of UserField
public string UserField
{
get
{
return user_field;
}
set
{
user_field=value;
}
}
//set-get property of Ip Address
public string IPAddr
{
get
{
return ip_addr;
}
set
{
ip_addr=value;
}
}
}
how can I change this order?
Thanks
|
|
|
|
|
You can use a DataGridTableStyle . See the documentation[^] - which includes an example - for the DataGrid.TableStyles property in the .NET Framework SDK. Table styles can be designed through the Windows Forms designer as well, and work best when your DataSet and DataTable structures are known, like when using typed DataSet s, which you can do by adding a new DataSet class to your project through the Add->Add New Item context menu. Either design the tables yourself or drag and drop tables, views, or stored procs from a database connection in your Server Explorer. Read Generating a Strongly Typed DataSet[^] and Creating Typed Datasets with the Component Designer[^] for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I'm trying to use the Microsoft.Web.Services2.Messaging.
ISoapFormatter
but I receive this error:
System.Xml.XmlException: The root element is missing.
at System.Xml.XmlTextReader.Read()
at Microsoft.Web.Services2.Xml.XmlSkipDTDReader.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at Microsoft.Web.Services2.SoapEnvelope.Load(Stream stream)
at Microsoft.Web.Services2.Messaging.SoapPlainFormatter.Microsoft.Web.Services2.Messaging.ISoapFormatter.Deserialize(Stream stream)
at WebSemantica.SoapSmtp.Mailbox.EndReceive(IAsyncResult result) in c:\wsf-projeto+final-julio\wsf-projeto final\websemantica\zutil-soapsmtp\mailbox.cs:line 307
----------------------------------------------------------
the code I'm using is (line 307 is the last line):
UTF8Encoding encoding = new UTF8Encoding();
SimpleMailMessage m = messagesArray[i];
ISoapFormatter formatter = new SoapPlainFormatter();
MemoryStream stream = new MemoryStream( encoding.GetBytes( m.TextDataString ) );
envelopes[i] = formatter.Deserialize( stream );
----------------------------------------------------------
if I print the xml (the "m.TextDataString") the result is:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rdf:RDF [
<!ENTITY meetingmaker "http://websemantica.puc-rio.br/2004/06/meetingmaker/meetingmaker#">
<!ENTITY ical "http://www.w3.org/2002/12/cal/ical#">
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">
]>
<soap:Envelope xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><wsa:Action>InvokeCoordinator</wsa:Action><wsa:MessageID>uuid:a341e5ea-e828-43c6-88e0-d74873ffd0af</wsa:MessageID><wsa:To>urn:websemanticaproxy</wsa:To><wsse:Security><wsu:Timestamp wsu:Id="Timestamp-89698a3f-20d7-400d-ae99-80583ac02d3b"><wsu:Created>2005-02-26T17:11:37Z</wsu:Created><wsu:Expires>2005-02-26T17:16:37Z</wsu:Expires></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><string xmlns="http://tempuri.org/">
<rdf:RDF
xml:base="&meetingmaker;"
xmlns:meetingmaker="&meetingmaker;"
xmlns:ical="&ical;"
xmlns:rdf="&rdf;"
xmlns:rdfs="&rdfs;"
xmlns:xsd="&xsd;"
>
<meetingmaker:MeetingMaker rdf:ID="meetingmaker_id">
<meetingmaker:criteria rdf:datatype="&xsd;string">majority</meetingmaker:criteria>
<meetingmaker:algorithm rdf:datatype="&xsd;string">parallel</meetingmaker:algorithm>
<meetingmaker:uid rdf:datatype="&xsd;string">julio@ntime.com.br-02-26-2005 02:11:35</meetingmaker:uid>
<meetingmaker:vevent>
<ical:Vevent rdf:ID="vevent_id">
<ical:location rdf:datatype="&xsd;string">Puc</ical:location>
<ical:summary rdf:datatype="&xsd;string">Apresentacao de Trabalho</ical:summary>
<ical:dtstart rdf:datatype="&xsd;datetime">12-10-2004 10:00:00</ical:dtstart>
<ical:dtend rdf:datatype="&xsd;datetime">12-10-2004 11:00:00</ical:dtend>
<ical:contact rdf:datatype="&xsd;string">julio@ntime.com.br</ical:contact>
<ical:attende>
<rdf:Bag rdf:ID="vevent_ateende">
<rdf:li rdf:datatype="&xsd;string">kid@teccomm.les.inf.puc-rio.br</rdf:li><rdf:li rdf:datatype="&xsd;string">fred.kid@gmail.com</rdf:li><rdf:li rdf:datatype="&xsd;string">fsilva@inf.puc-rio.br</rdf:li>
</rdf:Bag>
</ical:attende>
</ical:Vevent>
</meetingmaker:vevent>
</meetingmaker:MeetingMaker>
</rdf:RDF></string></soap:Body></soap:Envelope>
(whitch is a valid XML, at least the Internet explorer open it...)
|
|
|
|
|
Not sure but you might have more than one top level element which means no root. and if it is a long XML file, in the IE you may see the data on the top as if it is well-structured but when you scroll down, you might see that the second block of elements are in error.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
I am using .net with SQL server 2000 , I read the article Matt Newman wrote.. I Start to code but it gives an error like "C:\Documents and Settings\Aikanaro\Desktop\CES\Form1.cs(138): The name 'myConnection' does not exist in the class or namespace 'CES.Form1'"
But I already Decleared that at the beggining.. What could be the problem
Here is little of my code.. Please help
public Form1()
{
InitializeComponent();
SqlConnection myConnection = new SqlConnection("user id=username;" +
"password=password;server=localhost;" +
"Trusted_Connection=true;" +
"database=CES; " +
"connection timeout=30");
try
{
myConnection.Open();
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
|
|
|
|
|
Since we don't know what is on line 138 (which is where your error is) it is going to be difficult to help you pinpoint this.
The code you supply is the constructor for the class, in that constructor you declare a local variable called myConnection , which you initialise and then Open(). The constructor completes the myConnection goes out of scope (in other words it cannot be referenced any more)
Line 138, I can only guess, is outside the constructor and cannot access the local variables within the constructor. If you want to be able to access the variable myConnection from else where in the class you must declare it at the class level and not at the method level.
Does this help?
Cada uno es artifice de su ventura
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
private void button2_Click(object sender, System.EventArgs e)
{
SqlCommand myCommand = new SqlCommand("Command String", myConnection);
}
This is where line 137 , "myConnection" doen not recognized by the compiler
What can I do
|
|
|
|
|
The reson for the error message is that myConnection is not defined within the current scope. Scope can be simply thought of as the code between the braces { }. As you will have noticed a C# program has lots of opening and closing braces like this...
namespace MyNamespace
{
class MyClass
{
public void MyMethod()
{
for(int i=0;i<100;i++)
{
Console.WriteLine(i.ToString());
}
}
}
} Before each opening brace is some code that explains what the scope is for. e.g. class MyClass or public void MyMethod() to indicate the start of a level of scope.
In your original post you declared myConnection in the constructor, so it was local to the scope of the constructor. What you need to do is declare myConnection in the scope of the class (because you can only see what is in your scope + the parent(s) scope) then you can set value in the constructor.
For example:
namespace MyNamespace
{
class MyClass
{
private SqlConnection myConnection;
public void MyClass()
{
myConnection = new SqlConnection(....);
}
private void button2_Click(object sender, System.EventArgs e)
{
SqlCommand myCommand = new SqlCommand("Command String", myConnection);
}
}
}
Does this help?
Cada uno es artifice de su ventura
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
Thank you for your help and concern...
It helps quite much
|
|
|
|
|