|
Alternatively, you can do something like I did in this[^] reply if you don't want to handle the drawing of the entire control, this was for a pictureBox but works for other controls too.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Dear All,
I have a network program which has client and server.
The server will be listening the client at a specific port and IP address.
The client is connecting and writing the data to the server.
When the client connection is established the server will continuously listen the client and gets the packet sent by it.
When the time goes on the server takes up lots of memory in RAM and the CPU utilization goes to 80 to 100%.
The connection used was TCP.
Can any one tell me why this happens.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
M. J. Jaya Chitra wrote: CPU utilization goes to 80 to 100%
Probably because of incorrect usage of threads. Try to use asynchronous fashion methods (BeginXXX,EndXX) which is very efficient. Hard to tell more without seeing the code.
|
|
|
|
|
M. J. Jaya Chitra wrote: CPU utilization goes to 80 to 100%
looks like you are using while loop, instead of thread.
|
|
|
|
|
I am working on an assignment tt reads in *.cs files fr a given directory and do some evaluation with it. At first i thought it was just a small assignment, so Visual Studio is not required, then when i read my assignment requirement again, I find out tt I might require the use of Visual Studio (as our lec wants us to learn it for our upcoming big assignment).
And my code works under command prompt (can read all the *.cs files) but gives me a FileNotFound Exception when working under Visual Studio environment. Does anyone has any idea on how to solve this problem?
--------------------
C:\Documents and Settings\myname\My Documents\Visual Studio 2005\Projects\Stat
Generator\StatGenerator>StatGenerator.exe
Enter the directory name with the C# files to be evaluated:
C:\Documents and Settings\myname\My Documents\cs
Total of 3 C# files found.
File Name: StatGenerator.cs
author's_unix_id: myname
LOC without comments: 71
LOC with comments: 71
Comments lines: 0
File Not Found: Could not find file 'C:\Documents and Settings\myname\My Docum
ents\Visual Studio 2005\Projects\StatGenerator\StatGenerator\test.cs'.
Enter the directory name with the C# files to be evaluated:
|
|
|
|
|
Not sure I understand you - but when you build the project in VS it places the executable in a specific location (bin\debug by default) so that would be the folder from which any relative paths are generated - i.e. if your program tries to open a file called 'test.cs' without specifying a complete path, then it will just look in the same folder that the exe is in.
So - you could move your files to this folder, copy the exe from this folder to the folder containing the files, or specify the path to the folder containing the files in the program and be explicit when you open them.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
|
You see, this is what we don't want here. That screaming Subject annoys us
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
OK - as per your title.
There's the door. Don't let it hit you on the way out.
|
|
|
|
|
Hi,
I am busy with an NTier Windows Application that has the following:
Presentation Tier (Windows Application)
In the presentation Tier I have a form with a Combobox.
DataAccess Tier (Class library)
This tier contains the DataSet TableAdapters.
DataEntityTier (Class library)
This tier contains the DataSet Validation and Structure.
DataService (WCF)
This tier connects to the DataAccess tier in order to retrieve the data.
I have successfully implemented the GetData() method via the WCF service. How can I implement the Fill() method? I currently have a combobox that I have set the datasource, datamember and valuemember but nothing gets populated. How can I get the data from the dataset to the combobox using WCF??
IService1 File:
[OperationContract]
WBGTS.DataEntities.dsEntities.IndustryDataTable GetIndustries()
Service1 File:
public WBGTS.DataEntities.dsEntities.IndustryDataTable GetIndustries()
{
WBGTS.DataAccess.dsIndustryTableAdapter taIndustry = new WBGTS.DataAccess.dsIndustryTableAdapter();
return taIndustry.GetIndustries();
}
Windows Form:
Form_Load(object sender, eventargs e)
{
ServiceReference1.ServiceClient proxy = new ServiceReference1.ServiceClient();
dsEntities.Industries.Merge(proxy.GetIndustries());
}
Illegal Operation
|
|
|
|
|
can you tell me little bit more in which layer your method fill ...
have your values in datareader ,create some business object that can hold these values.
return it to the presentation layer ... and read the values again
using the interface method ".GetDataTable(your method )"
i think via this way u can populate the value...
vikas da
|
|
|
|
|
Hi All,
does anyone come across this problem "the selected file is a visual studio solution file, but was created by a newer version of visual studio and can not be opened." i was trying to open a asp.net application created by visual studio 2003.net about 2 years ago, and now i cant open it in visual studio 2003.net? what the hell?
I have both visual studio 2005 and visual studio 2003.net installed on my machine. is this could be the .net 2.0 framework issue?
plz help
|
|
|
|
|
AndieDu wrote: is this could be the .net 2.0 framework issue?
Visual Studio solution files have nothing to do with the .NET framework.
AndieDu wrote: I have both visual studio 2005 and visual studio 2003.net installed on my machine
Could you have inadvertently opened the solution in Visual Studio 2005 and upgraded the project?
If you look at the solution file in Windows Explorer does it have a version number in the icon? If it is a Visual Studio 2005 file it will have an 8 in the bottom corner, otherwise a 7.1
|
|
|
|
|
excellent mate, thanks a lot, i can see teh solution icon has 8 on it.
now the issue is that i neither can open in 2005 nor in 2003.net and i do need to open it in 2003.net due to compability issue. can you guide me through?
many thanks
|
|
|
|
|
You could try
Here[^]
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
I fix it myself, if anyone come across the same issue just shoot me an emial n i ll guide you through to get around of it.
many thanks..
|
|
|
|
|
Hello fellow developers,
For simplicity sake, I know you are all busy, I'll get to the meat of the question:
What would be the fastest way to search a .DLL, .EXE and .config for a String value?
Here is the background info:
I have completed an application that searches "Locations" for configuration settings. It works very well, my only complaint is the File Searching functionality appears to be quite slow. Normally for a localized search I use the WinGrep application www.wingrep.com, which works very well and amazingly fast ( its written in C, so it should be ). I basically want the same functionality that WinGrep provides but add a nice manager feel to it, hence the application I just finished. The application was built to help us unify our broad code base of 100s of applications writen by various developers over time. Specifically to find and replace connection strings and hard coded server references. For .configs, its easy, File.ReadAllText() and use RegEx, done... for Binaries ( DLL / EXE primarily ) it was a little more difficult. I need to search binaries because some applications we do not control the source for and would have to request a change from that company division.
For small files I did the following:
<br />
Byte[] fileData = File.ReadAllBytes(file.FullName); <br />
String fileAsString = System.Text.Encoding.Unicode.GetString(fileData);<br />
For larger files I did the below, taken from a suggestion on this site:
String line = null;
int lineNum = 0;
using (Stream stream = file.Open(FileMode.Open, FileAccess.Read))
{
byte[] readBuffer = new byte[16384];
int bytesRead = 0;
int offset = 0;
long filePos = 0;
while ((bytesRead = stream.Read(readBuffer, offset,
readBuffer.Length - offset)) > 0)
{
line = System.Text.Encoding.Unicode.GetString(readBuffer);
MatchCollection matches = regEx.Matches(line);
if (matches.Count > 0)
{
foreach (Match match in matches)
{
if (match.Success)
{
StoreMatch(match.Captures[0].Value);
}
}
}
filePos = stream.Position;
offset = (task.Search.Replacement.Length * 2);
for (int i = 0; i < offset; i++)
readBuffer[i] = readBuffer[readBuffer.Length - offset + i];
}
}
Here are the methods used to iterate thru a "Task" for a search location
private static TaskSearchResult SearchUNC(TaskSearch task)
{
if (!task.Location.Equals(_location))
{
_location = task.Location;
_locationFilePath = new DirectoryInfo(task.Location.Path);
}
task.Search = new SearchRegEx(task.Search);
TaskSearchResult taskResult = new TaskSearchResult();
taskResult.Result = true;
if (_locationFilePath.Exists)
{
taskResult.Combine(SearchFileLocation(_locationFilePath, task));
}
else
{
taskResult.Result = false;
taskResult.SearchResults.Add(new SearchResult(task.Location.Path, String.Format("Directory {0} does not exist", task.Location.Path)));
}
return taskResult;
}
private static TaskSearchResult SearchFileLocation(DirectoryInfo directory, TaskSearch task)
{
TaskSearchResult taskResult = new TaskSearchResult();
Console.WriteLine("* File Location being searched {0}", directory.FullName);
try
{
FileInfo[] files = directory.GetFiles(task.Location.Filter, SearchOption.TopDirectoryOnly);
foreach (FileInfo fi in files)
{
try
{
if (IsTextFile(fi))
{
taskResult.Combine(SearchFile(fi, task));
}
else
{
if (fi.Length > (1024 * 1024))
taskResult.Combine(SearchFileBinaryLarge(fi, task));
else
taskResult.Combine(SearchFileBinary(fi, task));
}
}
catch (Exception ex)
{
Console.WriteLine(String.Format("File :{0} Error: {1} \n", fi.FullName, ex.Message));
taskResult.SearchResults.Add(new SearchResult(task.Location.Path, String.Format("{0} - Error:{1}", fi.FullName, ex.Message)));
}
}
if (task.Location.IsRecursive)
{
DirectoryInfo[] directories = directory.GetDirectories();
foreach (DirectoryInfo subDirectory in directories)
{
taskResult.Combine(SearchFileLocation(subDirectory, task));
}
}
}
catch (Exception ex)
{
taskResult.SearchResults.Add(new SearchResult(task.Location.Path,String.Format("{0} - Error:{1}", directory.FullName, ex.Message)));
}
return taskResult;
}
The IsTextFile(File file) method simply does a check in the registry for the extention and it checks for known Text Type files, its good enough for the scope of this application although I would love some feed back on that as well.
In conclusion, I would love any feedback you can provide, let me know if you need to see more code.
Kind Regards,
Ryan
|
|
|
|
|
Wow, I didn't even realize how bad the performance was... I tried to read a \bin folder with 11 .dlls all under 500kb and it takes well over 15 minutes. This is running on a VM on a Blade Server. So it is definately not the environment that I can tell... absolutely insane and very frustrating.
|
|
|
|
|
|
I am trying to find a way to display the contents of multiline textbox on a print preview page to display and print the entire contents of what the user has typed in. Once the user types in data in the multiline textbox, the data is stored in a SQL database and then retrieved to be displayed on a print preview page to be printed? Any ideas? Sorry if the question is a little easy for some of you but I am a newbie to C# and .Net prgramming. Thanks is advance.
|
|
|
|
|
|
I am using the following code to display a simpel report using crystal report but though I am passing the parameter in my sql command, the parameter dialog box of crystal report promopts to enter the vehicle_id parameter value.
How can I get rid of that dialog box and make sure my parameter is passed from my C# code?
data_set = new DataSet();
sql_connection = new SqlConnection("Data Source=.\\SQLEXPRESS;initial catalog=rent_a_car_company;integrated security=true");
sql_connection.Open();
sql_command = new SqlCommand("sp_get_agreement_by_id", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_command.Parameters.Add("@vehicle_id", SqlDbType.Int).Value = 1;
sql_adapter = new SqlDataAdapter(sql_command);
sql_adapter.Fill(data_set);
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(@"C:\Users\Jassim\Documents\Visual Studio 2008\Projects\Taajeer\Taajeer\agreement.rpt");
rptDoc.SetDataSource(data_set);
crystalReportViewer1.ReportSource = rptDoc;
|
|
|
|
|
Sounds like you have defined a parameter field in the report. Do you still need that if your command already restricts the data using that parameter. If not, could yo simply remove it from the report.
|
|
|
|
|
i need that parameter in my report to pass the vehicle_id bt I need to pass the value from my C# project unless there is a better way to do it.
|
|
|
|
|
jrahma wrote: I need to pass the value from my C# project
You can set the value of a parameter field with code somewhat like this:
ParameterDiscreteValue paramValue = new ParameterDiscreteValue();
paramValue.Value = 1;
rptDoc.ParameterFields["vehicle_id"].CurrentValues.Add(paramValue);
jrahma wrote: unless there is a better way to do it
Don't know what you have as data in the dataset you use as a datasource, but couldn't the stored procedure return the parameter value it receives as part of the data it returns? This way you would always have the vehicle_id in the data.
|
|
|
|