|
What can I do then I have 5 ports with greater than 70000. Do we have any other object that I can use for this scenario?
Thanks for the help
/Dabuskol
|
|
|
|
|
I don't know how you have any ports greater than 65535 as TCP [The underlying protocol] does not support it. It has nothing to do with the .NET Framework.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Ok. I will check with our administrators why he is sending me these ports. Sorry, I'm new to IP/PORT thing
I thought it's .net problem
/dabsukol
|
|
|
|
|
dabuskol wrote:
I think int32 is not enough for the value=70252
Your question was already answer correctly (TCP doesn't support ports about 65535), but an Int32 - if you read the documentation and if you know anything about bits - is plenty large enough to hold the value 70252.
An Int32 is a signed 32-bit integer that can hold 2^32 bits of data. Because it's signed, it can have a negative value. This value can range from -2,147,483,648 to 2,147,483,647. 70252 easily falls within that range.
As Colin said, this problem has nothing to do with .NET.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Since I received good answers on my previous question I'll go for a new.
I have a richtextbox and like to highlight lines that contain a specific string.
I'v found the .Find method which lets me search for a string and then with the selection methods I can highlight by changing font and foreground colour etc.
But the problem is that only the search string becomes selected and not the whole line. Also only the first occurrence is selected but I guess that's solvable.
Is there some way to achieve this with .Find or is there any other way I can/should go?
|
|
|
|
|
Looking at the richtext control in a prototype project I built, it indicates that display.Find() returns an index of the found line of text.
So it may be possible to make use of the display.GetLineFromCharIndex() using the result form Find();
So your final code would be this:
RichTextBox display = new RichTextBox();
...
public void SetLine(string textToSelect)
{
int locate = display.Find(textToSelect);
int linePos= display.GetLineFromCharIndex(locate);
this.SetSelectedStyle();
display.SelectedText = display.Lines[linePos];
}
The approach I took to determine this was to create a blank project.
Add a richtext control.
Create a dummy method in the project so that I can see exposed properties and methods.
Start looking at 'WHAT' for the return type and description of Find();
See what is exposed that deals with lines based on character position.
See what collection might be used for the output of that.
______________________________
The Tao gave birth to machine language.
Machine language gave birth to the assembler.
The assembler gave birth to ten thousand languages.
Each language has its purpose, however humble.
Each language expresses the Yin and Yang of software.
Each language has its place within the Tao.
Beauty exists because we give a name to C#.
Bad exists because we give a name to COBOL.
|
|
|
|
|
OK, I tried that and it worked somehow but there's still a problem.
Given the code below I search for the string "string" and then select the line that contains the string "This is the string I search for". The result will be that string is replaced and highlighted and thus giving:
"This is the This is the string I search for I search for".
I have tried several solutions avoiding this, but I assume I need to use SelectedText.Replace or set Select to start from the beginning of the line
But I can't find out a way to calculate where the line starts and ends.
Anyone that can hint how to proceed?
private void WinForm_Load(object sender, System.EventArgs e)
{
richTextBox1.Text = "Hello world\n";
richTextBox1.AppendText("This is the string I search for\n");
richTextBox1.AppendText("The last row\n");
}
}
private void button1_Click(object sender, System.EventArgs e)
{
int locate = richTextBox1.Find("string");
int line = richTextBox1.GetLineFromCharIndex(locate);
richTextBox1.SelectionColor = Color.Red;
richTextBox1.SelectedText = richTextBox1.Lines[line];
string q = richTextBox1.Lines[line];;
richTextBox1.SelectionProtected = true;
int len = richTextBox1.Lines[line].Length;
string txt = richTextBox1.Lines[line];
richTextBox1.SelectionCharOffset = 5;
richTextBox1.AppendText("Line no: " + line + ", Locate: " + locate + ", Len: " + len + "\n");
richTextBox1.AppendText(txt + "\n");
richTextBox1.AppendText("q: " + q);
}
|
|
|
|
|
Dunno what I was thinking about yesterday since it was pretty obvious.
private void onLoad(object sender, System.EventArgs e)
{
richTextBox1.Text = "Hello World\n";
richTextBox1.AppendText("This is the string I search for\n");
richTextBox1.AppendText("Another Hello World Again\n");
}
private void button1_Click(object sender, System.EventArgs e)
{
int loc = richTextBox1.Find("string");
int linePos= richTextBox1.GetLineFromCharIndex(loc);
int lineLen = richTextBox1.Lines[linePos].Length;
int lineStart = richTextBox1.Lines[linePos].IndexOf("string");
richTextBox1.Select(lineStart,lineLen);
richTextBox1.SelectionColor = Color.Blue;
richTextBox1.SelectedText = richTextBox1.Lines[linePos];
richTextBox1.AppendText("strPos: " + loc + ", Len: " + lineLen + ", linestart: " + lineStart);
}
|
|
|
|
|
I want to access a class (TestClass) that is in a given assembly(Test.dll) on my machine.
I use activator :
ObjectHandle objH=null;
objH=Activator.CreateInstanceFrom(@"\\Daniel\SharedDocs\Test.dll","TestClass");
TestClass tc=(TestClass)objH.Unwrap();
MessageBox.Show(tc.GetCompName());
But I get this error : "Required permissions cannot be acquired."
What should I do?
Thanks,
Daniel.
|
|
|
|
|
You should not load the DLL from a network path... instead use a local copy. Or change the default security settings in "Control Panel".
|
|
|
|
|
The exception type is : System.Security.Policy.PolicyException
I think it has somthing to do with SecurityPermission and ReflectionPermission...
|
|
|
|
|
Daniel Zaharia wrote:
The exception type is : System.Security.Policy.PolicyException
I think it has somthing to do with SecurityPermission and ReflectionPermission...
No, it has something to do with the Policy!!!
So either change your policy to allow executiong ffrom network shares or change the way you load your assembly!
|
|
|
|
|
You need to add a code group with a URL or Site membership condition with the necessary privileges (or simply FullTrust permissions) for the directory (or any parent directory) to allow execution from that directory.
For example, using a URL membership condition, use file://MYSERVER/SHARE/* or something like that. Be sure to add the asterisk at the end as a wildcard unless you only want to apply the policy to only one assembly (which, of course, you should include the assembly name).
You should read Understanding .NET Code Access Security[^] here on CodeProject for more information. It's a good read and a comprehensive resource of what you can find scattered throughout the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
I get the same error even if i try to load the assembly from the same directory with the executing assembly.
objH=Activator.CreateInstanceFrom("Test.dll","TestClass");
|
|
|
|
|
Can some1 pls tell me what's wrong with my coding? thank u.
<%@ Page Language="C#" Debug="True" %>
int AddUser(string fname, string sname, string username, string password)
{
string connectionString = "server=\'\'; user id=\'\'; password=\'\'; databas" +
"e=\'\'";
System.Data.IDbConnection dbConnection = new System.Data.SqlClient.SqlConnection(connectionString);
string queryString = "INSERT INTO [Members] ([fname], [sname], [username], [password]) VALUES (@fname, " +
"@sname, @username, @password)";
System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = dbConnection;
System.Data.IDataParameter dbParam_fname = new System.Data.SqlClient.SqlParameter();
dbParam_fname.ParameterName = "@fname";
dbParam_fname.Value = fname;
dbParam_fname.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_fname);
System.Data.IDataParameter dbParam_sname = new System.Data.SqlClient.SqlParameter();
dbParam_sname.ParameterName = "@sname";
dbParam_sname.Value = sname;
dbParam_sname.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_sname);
System.Data.IDataParameter dbParam_username = new System.Data.SqlClient.SqlParameter();
dbParam_username.ParameterName = "@username";
dbParam_username.Value = username;
dbParam_username.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_username);
System.Data.IDataParameter dbParam_password = new System.Data.SqlClient.SqlParameter();
dbParam_password.ParameterName = "@password";
dbParam_password.Value = password;
dbParam_password.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_password);
int rowsAffected = 0;
dbConnection.Open();
try {
rowsAffected = dbCommand.ExecuteNonQuery();
}
finally {
dbConnection.Close();
}
return rowsAffected;
}
void Button1_Click(object sender, EventArgs e)
{
if AddUser(txtUserName.Text, txtUserPassword.Text) > 0
Message.Text = "Success";
else
Message.Text = "Failure";
}
<asp:label id="Label1" runat="server">User Name
<asp:textbox id="txtUserName" runat="server">
<asp:label id="Label2" runat="server">Password
<asp:textbox id="txtUserPassword" runat="server" textmode="Password">
<asp:label id="Message" runat="server">
<asp:button id="Button1" onclick="Button1_Click" runat="server" text="Register">
|
|
|
|
|
You could try the ASP.NET forum[^]
Also, I don't think people are going to go through all that code looking for your error without an idea of what they are looking for. What error message do you get? What exacly goes wrong?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Hi ,
I want to add a style to the particular row's text in datagrid....as my datagrid is directly take the data from store procedure....
datagrid2.datasource=ds;
datagrid2.databind();
i want to add the style like whenever my mouse is over on that text i want to change the cursor as a hand.
In the css file i created a style for the hand named "hand" ....that's the same i m using in the following code....
datagrid2.Items[i].Cells[1].Style.Add("onmouseover","hand");
plz help me....
Thanks..
|
|
|
|
|
This question really belongs in the ASP.NET forum. It has nothing to do with the C# language itself, even though it's written in C#.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I use PowerPoint 2003 to record the following macro:
<br />
Sub Macro1()<br />
<br />
Presentations.Add WithWindow:=msoTrue<br />
ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=1, Layout:=ppLayoutText).SlideIndex<br />
ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:="C:\SAVE\1_files\PSPage1.bmp", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=9, Top:=22, Width:=702, Height:=496).Select<br />
ActiveWindow.View.Paste<br />
With ActiveWindow.Selection.ShapeRange<br />
.IncrementLeft 165.88<br />
.IncrementTop 79.88<br />
End With<br />
End Sub<br />
Now I want to implement it in my C# project,
<br />
ppApp = new PowerPoint.Application();<br />
objPres = ppApp.Presentations.Add(MsoTriState.msoTrue);<br />
objSlide = objPres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutText);<br />
objShape = objSlide.Shapes.AddPicture:="C:\\SAVE\\1_files\\PSPage1.bmp",MsoTriState.msoFalse,MsoTriState.msoTrue,9,22,702,496);<br />
I can add a slide and insert the Picture,
but I don't know how to do
ActiveWindow.View.Paste
to paste the object I write into clipboard,
Can anyone tell me how to do this in C#...??
Thanks a lot !!
|
|
|
|
|
Anything you can do in VB6 (and older) you can do in a managed languages that supports COM interoperability (just about all of them, including C# and VB.NET). It's all based on OLE/COM automation described in a typelib that you can create an interop assembly from. This interop assembly is also known as a Runtime Callable Wrapper (RCW), which marshals calls from managed to unmanaged.
Unfortunately, though, it's not always as clear what to do as it is with VB (pre-.NET) because not all the type information is reserved. Properties and parameters start being the most basic class: object .
The primary interop assemblies (PIA - typically assemblies created by the developers of the corresponding typelib, and registered in a way that when you reference that typelib the PIA is used automatically instead of a new one being generated) for Office 2003 declare a DocumentWindow.View property, of type View . View.Paste is defined, so you would use:
ppApp.ActiveWindow.View.Paste();
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi there,
It's fairly easy to create a System.Drawing.Color with any RGB value one wishes. It's also easy to get this color HSB values by using System.Drawing.Color.GetBrightness , System.Drawing.Color.GetHue and System.Drawing.Color.GetSaturation member methods.
But can anyone help me create a color from Hue, Saturation and Brightness (HSB) values?
|
|
|
|
|
|
|
Hi ,
I want to add a style to the paricular row's text in datagrid....as my datagrid is directly take the data from store procedure....
datagrid2.datasource=ds;
datagrid2.databind();
i want to add the style like whenever my mouse is over on that text i want to change the cursor as a hand.
In the css file i created a style for the hand named "hand" ....that's the same i m using in the following code....
datagrid2.Items[i].Cells[1].Style.Add("onmouseover","hand");
plz help me....
Thanks..
|
|
|
|