|
I has a server program.The program natural run at console.
Now I create a Windows Service project and attach server program in.In ProjectInstaller class.I use NetworkService acount.
This server program can success runing.But it cannot natural send UDP data.
My client cannot receive data.
Please help me .thanks!
Ray Lynn
-- modified at 22:05 Tuesday 21st February, 2006
|
|
|
|
|
I'm using System.Configuration in .NET 2.0 to load in values
from an externally specified config file and deserialize
them into a C# class. During deserialization, I'm getting
an exception thrown by .NET It's having a problem with
the <connections> element seen below. I've tried different things, but
still I can't get the deserialize to succeed. Here's the problem in
detail below.
Can anybody tell me what I'm doing wrong? Shouldn't
[xmlArray] work?
Thx,
Tom
The app.config file looks like this:
<configuation>
<configSections>
<section name="dataAccessSection" type="Framework.Data.DataAccessConfig,Framework.Data,Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null"/>
</configSections>
<dataAccessSection configSource="DataAccess.config"/>
</configuation>
DataAccess.config looks like this:
<dataAccessSection>
<connections>
<connection name="fsa">
<connectionEnvs>
<connectionEnv envName="INT1" assembly="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="System.Data.OleDb.OleDbConnection" connectionString="Provider=OraOLEDB.Oracle;Password={0};Persist Security Info=True;User ID=fiisbsvc;Data Source=dbenv022" connectionStringPassword="lttC8Hg29Nfks+3QPI8Hxg==">
</connectionEnv>
</connectionEnvs>
</connection>
</connections>
<commands/>
<maps/>
</dataAccessSection>
The C# class looks like this:
using System;
using System.Xml.Serialization;
using System.Configuration;
namespace Framework.Data
{
/// <summary>
/// Represents the root of all data access configuration information.
/// </summary>
public class DataAccessConfig : ConfigurationSection
{
#region Constructor(s)
/// <summary>
/// Initializes a new instance of the <see cref="DataAccessConfig"/> class.
/// </summary>
public DataAccessConfig()
{
_sectionName = _defaultSectionName;
}
#endregion
#region Config Manager
private const string _defaultSectionName = "dataAccessSection";
private string _sectionName;
#region Connection Config
private ConnectionConfigCollection _connections = new ConnectionConfigCollection();
/// <summary>
/// Gets or sets the collection of connection configuration items associated with this application.
/// </summary>
/// <value>The collection of connection configuration items associated with this application.</value>
[XmlArray("connections")]
[XmlArrayItem("connection")]
// [ConfigurationProperty("connections")]
// [ConfigurationCollection(typeof(ConnectionConfigCollection))]
public ConnectionConfigCollection Connections
{
get
{
return _connections;
}
set
{
_connections = value;
}
}
.
.
.
}
|
|
|
|
|
Hello all,
Does anyone know how to add commands to the bottom of a property grid at runtime? Let me describe my situation.
I've created a class called PropertyGridProxy that implements ICustomTypeDescriptor and can be initialized with any object. At the moment, most things simply pass through to the default TypeDescriptor implementation. However, that's soon to change, as I will be creating some attributes that help me in working with the property grid. This ICustomTypeDescriptor implementation will read those attributes to produce the list of possible values for some of the properties exposed in the grid (instead of just using the default implementation).
Now, I've also created a designer that should (theoretically) wrap PropertyGridProxy for the property grid's consumption. It inherits from System.ComponentModel.Design.ComponentDesigner and overrides the Verbs property, which should return a DesignerVerb collection. I've applied the following attribute to the top of the PropertyGridProxy class:
[Designer(typeof(PropertyGridProxyDesigner))]
This should work according to the (rather useless) documentation I've found so far on MSDN, but it doesn't seem to be picking up the PropertyGridProxyDesigner class. I even had the designer throw an exception in its constructor, but nothing ever came of it. I therefore suspect that it isn't being called at all. Needless to say, the verbs property is never being used. Have I done something wrong?
Oh, the code in the Verbs property is as follows. ActionVerb is a custom attribute class that lets you tack a string name onto a method for calling it from a UI:
<br />
public override DesignerVerbCollection Verbs<br />
{<br />
get<br />
{<br />
System.Diagnostics.Debug.Write("Verbs collection accessed.");<br />
DesignerVerbCollection ret = new DesignerVerbCollection();<br />
PropertyGridProxy pGrid = this.Component as PropertyGridProxy;<br />
if (pGrid != null)<br />
{<br />
Type t = pGrid.TargetType;<br />
foreach (MethodInfo mi in t.GetMethods())<br />
{<br />
foreach (object o in mi.GetCustomAttributes(true))<br />
{<br />
ActionVerb attrib = o as ActionVerb;<br />
if (attrib != null)<br />
{<br />
Delegate handler = EventHandler.CreateDelegate(t, this.Component, mi);<br />
EventHandler eh = (EventHandler)handler;<br />
DesignerVerb verb = new DesignerVerb(attrib.VerbText, eh);<br />
ret.Add(verb);<br />
}<br />
}<br />
}<br />
}<br />
<br />
return ret;<br />
}<br />
}<br />
Thanks,
Will
|
|
|
|
|
Hello,
I'm tying to create a form (form2) which has a label on it and is being activated from another form (form1). The catch is that form2 needs to be displayed for 10 seconds and then disappear. I have tried many methods including importing the sleep function from Kernel32.dll like this:
frm2 = New Form2();
frm2.Show();
Sleep(10);
frm2.Close();
but the result was and empty window the labelwas not seen.
I also tried to run a thread that acivated a function that launched the form then used Thread.Sleep(10000) but the results were the same.
I also tried to make a loop for(i=0;i<10000000;i++)... after frm2.Show()
and also the result did not change empty window.
Am i missing somthing here I'm getting real frustrated and would very much appreciate any help about this issue.
Thanks
|
|
|
|
|
|
Hi,
Thanks for the advice
Should i place the timer control in form1 or in form2?
Thanks
|
|
|
|
|
It Worked.
Thank you very very much KaptinKrunch you
are really a life saver.
God Bless You
|
|
|
|
|
Hey guys,
got a problem. is there any way to align a text inside a graphics object from bottom to top without rotating the whole canvas itself? .net only provides an alignment from top to bottom and rotating the bloody canvas is too complicated since there are too many other accesses on that canvas. thanks a lot in advance.
-- modified at 17:44 Tuesday 21st February, 2006
|
|
|
|
|
Why not just rotate the canvas, then rotate it back to its original position when you're done with it. This way you can always assume your canvas is right-side up before dealing with any transformations on the canvas.
That said, have you looked at the StringFormat class?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
Hello!
Hope you all will be fine, I have a question about printing of a Page in Visual Studio 2003 by using C#, I have created a button and want to print a Page against the click Event of button without showing the Crystal Report Viewer,The values to be print can be from Datagrid (Dataset),Labels,Textboxes etc... How is it possible Please send me some code or sample project for it, I will be really thankful to you.
Regards,
AbuBakar Malik
|
|
|
|
|
hi
i want to writing 3d program in c# , i believe that OpenGL is good for this, how to use opengl in c#?
please give me OpenGL sdk for download and tutorial from very beginner to professional.
and i am 3dsmax user.
thanks.
|
|
|
|
|
|
I'm a C# newbie so execuse my ignorance. I'm coding a client server application. One of the problems i've run into is that when the client is initially loaded and can't find a network connection to the server, i get this ugly .NET error message. I would like to be able to check for a network connection before loading the program. Please help!!!!
|
|
|
|
|
You can do this two ways: the nice one and the bold one.
Let's start with the bold one.
try {
}
catch {
}
finally {
}
The nice way is to actually check using the WinAPI if there is a connection.
The following functionality checks for an internetconnection:
[DllImport("WININET", CharSet=CharSet.Auto)]
static extern bool InternetGetConnectedState(
ref InternetConnectionState lpdwFlags,
int dwReserved);
[Flags]
enum InternetConnectionState: int
{
INTERNET_CONNECTION_MODEM = 0x1,
INTERNET_CONNECTION_LAN = 0x2,
INTERNET_CONNECTION_PROXY = 0x4,
INTERNET_RAS_INSTALLED = 0x10,
INTERNET_CONNECTION_OFFLINE = 0x20,
INTERNET_CONNECTION_CONFIGURED = 0x40
}
[DllImport("wininet.dll", SetLastError=true)]
static extern int InternetAttemptConnect(int dwReserved);
Here is a simple example showing a messagebox if with the connection state:
InternetConnectionState flags = 0;
InternetGetConnectedState(ref flags, 0);
MessageBox.Show(String.Format("InternetState : {0} - {1}",(InternetGetConnectedState(ref flags, 0)?"ONLINE":"OFFLINE"),flags));
I suggest going to http://www.pinvoke.net[^] for more win API for connection checks.
|
|
|
|
|
I'm using .NET 2.0 and I have a Windows Forms app in which I want to create an rdlc report - this is the Reporting Services-type report you get in VS 2005.
I want to have an object as a datasource for the report, and I have no problem setting, populating, or binding the "top-level" object into the rdlc report, until I try to "nest" an object.
For example, I have a "Shipping" object in which a person has placed an order on a certain date, to a certain address. Has some other info like tracking number. This Shipping object will have one or more "LineItem" objects, which obviously is what they purchased.
I can bind the Shipping object to the rdlc report, but when I try to create a table, or grouping, or any list or anything on the LineItem subset, I can't figure out how to do this, if I can.
Has anyone tried this? Have any tips?
Thanks very much in advance.
Susan H
|
|
|
|
|
I have this weird comparision to do.
Any idea or suggestions are really appreciated
one decimal digit will be like 900.0 where 9 means optional and 0 means Required.
and 2nd # will be 88.8 which I have to compare and say it's valid because
decimal is required 2 digit on left are required and one digit on right .. so what ever is required are there.
8888.88 is not valid since 3rd digit is optional but cannot have more than that.
1.8 is not valid since at least 2 digit on left and one on right are required.
Thanks
|
|
|
|
|
Use a Regex object with the pattern "^\d{2,3}\.\d$" to verify the value.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks and sorry.
Thanks for your help amd sorry i didn't get it.
Thanks
|
|
|
|
|
Hello,
I'm trying to use tristate checkboxes in my TreeView control. But I can't find how. The Checked property is bool , and I was expecting a CheckState property that isn't there. So, .NET 2.0 seems not to support it but I'm sure I have seen them (the indeterminate checkboxes) in other apps.
Am I overlooking something?
Thanks!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Nope, you're not missing anything. I have some code that will do what you what, but I can't post it as an article since the bulk of it was taken from another article elsewhere, but I don't recall from where.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
As has been said, no, you're not missing anything. The way to do it is to use imagelists with graphics stolen from elsewhere and just set the item to the check in question. You'd have to override mousedown to determine if a click is on-top of the image and then switch it to the appropiate image.
That said, I'm sure there are third-party controls that already do it, but I never looked into it myself.
|
|
|
|
|
how can i convert this code to c#
especially the ReDim Preserve...
Public Function Get_Key(ByVal KeyPath As String, ByVal KeyName As String, ByVal host As String) As String
Dim RKey As Byte()
Dim ilByte As Integer
Try
Dim Key As Byte() = Get_Reg(KeyPath, KeyName, host)
ReDim Preserve RKey(14)
For ilByte = 52 To 66
RKey(ilByte - 52) = Key(ilByte)
Next ilByte
Catch ex As Exception
Return ""
Exit Function
End Try
Return ""
End Function
PAO
|
|
|
|
|
superPaul101 wrote: especially the ReDim Preserve
The .NET framework Array class has a static Resize method that should do the job.
|
|
|
|
|
how am i going to code it?
Wjousts wrote: The .NET framework Array class has a static Resize method that should do the job.
PAO
|
|
|
|
|