|
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
|
|
|
|
|
As Colin pointed out, myConnection is declared in the method scope of th form1 constructor, so is only available within the constructor. Move the declaration outside of the constructor (i.e) public class Form1:...
{
private SqlConnection myConnection = null; //declared at class level scope
form1()
{
myConnection = new SqlConnection(...); //instantiated in constructor
...
}
...
}
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
Dear CPians...
I have this pattern wich I can't assign to a variable. How can I escpae this:
<\s*DIV((\s*\w*)\s*=\s*("[^"]*"|'[^']'|[^>]*))*>.*<\s*/\s*DIV\s*>
theJazzyBrain
Excellence is not an act, but a habit! Aristotle
|
|
|
|
|
|
thank you .. it works!
theJazzyBrain
Excellence is not an act, but a habit! Aristotle
|
|
|
|
|
Really? How about
string myPattern = @"<\s*DIV((\s*\w*)\s*=\s*("[^"]*"|'[^']'|[^>]*))*>.*<\s*/\s*DIV\s*>";
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yeap,
tried that already but it doesn't work.
There is some problem with these characters :
[
]
these wont escape!
try it out on VS. you will get a
Syntax error, ']' expected
Thank you! :P
theJazzyBrain
Excellence is not an act, but a habit! Aristotle
|
|
|
|
|
Whoops! My bad. The problem is not with the '[' and ']' characters, but with the quotes that I didn't see inside your string. When using the '@' sign in front a a string literal, in order to get a double quote into the string, instead of denoting the end of it, you have to double it up, like:
string myPattern = @"<\s*DIV((\s*\w*)\s*=\s*(""[^""]*""|'[^']'|[^>]*))*>.*<\s*/\s*DIV\s*>";
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yup!
thank you
theJazzyBrain
Excellence is not an act, but a habit! Aristotle
|
|
|
|
|
Dear,
i want to make a lan messenger in C#, HOw?
Awaiting
|
|
|
|
|
You open Visual Studio, create a Windows Forms application project, add whatever UI controls you need to the form, and hang some code on the controls to do the actual processing of your user interface. Oh! You'll also need to add a class to the project and supply the code to pass message back and forth over the network, as well as manage connections to multiple clients, or possibly a chat relay server.
Next question! Maybe being MUCH more specific in scope would help. Like what part of this project are you having problems with?!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dear
i check simple messenger code from site c-sharpcorne.com By Muhammad Al But i didn't able to run it even demo also didn't work if u have more info in this please send me or any link from where i can see about it,
Thanx For +ve Response
|
|
|
|
|
--Using [VS C#.NET]--
Given a main C# form (main.cs Design/Code) and a threaded worker (worker.cs: inherists from a Threaded class that has functions: LockRead and LockWrite implemented)
What I plan on doing is the following:
When the user presses a button I create my new workers as follows (in my main.cs: private void btn1_Click(object sender, System.EventArgs e))
Worker 1Worker = new Worker(Device, File, Task);
Where variables device, File, Task are required information for the worker to perform its task.
Now, my main.cs form also has a Timer (timer_Refresh) that I use to refresh all my GUI (datagrids, combo boxes, etc) so I thought that at this point the timer_Refresh_Tick event could READ the status of the thread and display it in the GUI (is it STRTATING, PROCESSING, FINISHING, etc…)
My main problem is, how to communicate between the main.cs [which has the timer_Refresh_Tick event] and the Worker threads [like 1Worker] to get the status? (shared ressource)
I thought of using a simple array or dataset to store the status of each thread but I can’t seem to figure out how to “share the resource” so that both can access it (and how to implement LockRead and LockWrite accordingly for this resource).
- Worker thread must be able to access it to update its status as it goes
- main.cs timer_Refresh_Tick must be able to access it to read the new status every tick and display it in the datagrid
Using a table/database to store the information is a possibility (creating a [Task] DB Table) and then I will have a Table that both can access [create db connection objects in both] but I am sure there is something way better (like using a custom class…. String[] array…..dataset……?)
I hope this helps show you where I am stuck…
Thanks,
|
|
|
|
|
Hi, everyone,
I have a question when I use the following code to get the response.
WebRequest req = WebRequest.Create(sURL);
try
{
WebResponse result = req.GetResponse();
}
catch(Exception){}
the code works very well on my XP, but when I run it under Windows server 2000, or some others PC, I sometimes get the exception:
The underlying connection was closed: The server committed an HTTP protocol violation.
it comes with the code GetResponse(). But when I use IE try the Url, IE works.
Would you please tell me why that is happened, and How to avoid/fix that, so I can read the response.
Thanks a lot in advance!!
Alan Shen,
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
If you're sure the code is ok,
1. The .NET Framework versions on XP and Win 2000 server might be different and may cause problems.
2. If it is a specific server you are connecting, it might have a configuration that determines how to response depending on the client-type/platform that is trying to connect.
Just a thought.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Can you please help me in my problem?
I have a socket prog. application like
http://www.codeproject.com/dotnet/csharpwhiteboard.asp
My application is chat application like above architecture.
I want to bypass firewall as well as proxy if any on two chat clients like yahoo or msn can chat beyond proxy/firewalls...
Please guide me, how i can do that...!
Thanks,
Mahesh Devjibhai Dhola
"Empower yourself..."
|
|
|
|
|