|
Hi,
I have developed one windows service application using C# 2.0.
I have class for read and write value in INI File. In INI file I have storing the database path.
I need to get the path value in windows service class. So I have used the following function for read and write the value in INI File.
[DllImport("kernel32")]
public static extern long WritePrivateProfileString(string SectionName, string KeyName, string Value, string FileName);
[DllImport("kernel32")]
public static extern int GetPrivateProfileString(string SectionName, string KeyName, string DefaultValue, StringBuilder Value, int Size, string FileName);
I called this function in start service
public void StartPPdbService()
{
// Get DB path
StringBuilder tmpPath = new StringBuilder(255);
try
{
MyWin32.GetPrivateProfileString("PPdb", "path", ".\\DB\\", tmpPath, 255, Gen.IniName);
PPGen.DBpath = tmpPath.ToString();
if (!PPGen.DBpath.EndsWith("\\"))
{
PPGen.DBpath += "\\";
}
}
catch (Exception e)
{
// Insert Open in db log
PPGen.Log("DB", e.Message.ToString(), Visible);
}
finally
{
// Insert Open in db log
PPGen.Log("db", PPGen.DBpath.ToString(), Visible);
}
}
The above code return only default value not in INI file value.
Thank you,
Best regards,
Sundar
B.Sundarapandian
|
|
|
|
|
If you are using 2.0 then you should use app.cofig, not antiquated techniques like ini files.
only two letters away from being an asset
|
|
|
|
|
Hi Mr.
Thank you for the reply.
My application already have version of 3. Now I making the enhancement. already they did in console application. Now I make a windows service as well as console application.
We can able to run a windows service application as a Console application.
So I need to use the same way of storing process of INI file.
Thank you,
best regards,
B.Sundarapandian
|
|
|
|
|
Hi
I am new to ASP.Net.I have created a file system based web application.I tried to view it in browser.I can do so when i do http://localhost:portno/<project name="">.However I cannot view it when i do http://<computername>:portno/<project name="">.I cant unserstand where the problem is.I have placed the project inside wwwroot and have webshared it well.I have allowed it in network sharing too.Another thing that is confusing me is when i dont give the port no that is http:/<computer name="">/<project name=""> it shows me the directory listing of tegh project .But when i click on any of the aspx page,the following error is shown in the browser:
"The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
A name was started with an invalid character. Error processing resource 'http://jeri/joint/Default.aspx'. Line 1, Position...
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
-^"
Please help! I know very little about IIS settings and all.Thanks in advance!!
confusedme
|
|
|
|
|
hi
if i understand your question you want to browse your website on Lan the way is to add the file system web site to vertual directory you can do it like this:
open control panel --> adminstrative tools --> IIS
when you open it look at left side of the window and right click on web site default in web sites in your local computer tree.
on the right menu choose new --> virtual directory that will launch wizard
. alias name will be the website name
. in the browse window put your project folder
. in the permision put what you see necessary
and now you can see your website like this
http://localhost/'your web site name'
or if you are o lan any one can write your ip/'site name' and he will see your web site
. it's not necessary to put your file system project in wwwroot folder and this is one of it's benefit
gain i hope i understand your question
have nice day
|
|
|
|
|
hi there!Thanks for the reply!!
I did wat u said.Now i can see the directory listing when i do http://localhost/mywebsitename in my computer.But when i click on any of the pages of the directory the message is like:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
A name was started with an invalid character. Error processing resource 'http://localhost/joint/Default.aspx'. Line 1, Pos...
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
-^
And i cant see even the directory listing in my LAN when i do http://ipadd//mywebsite or http://ipadd//aliasname.It says page cant be displayed.
Please help!
confusedme
|
|
|
|
|
confusedme wrote: I can do so when i do http://localhost:portno/.However I cannot view it when i do http://:portno/
Of course it doesn't work. http://:portNumber isn't a valid URL. You didn't tell the browser which host to connect to to request the page. If you specify a port number you must specify the host, either by name or IP.
|
|
|
|
|
thanks for the reply..There was some kind of typing error in that .Of course i gave the servername...it was like this:
I can do so when i do http://localhost:portno/project name.However I cannot view it when i do http://hostname:portno/project name.I want to run it in LAN.Please Help!
confusedme
|
|
|
|
|
I'm doing a C# application and want to do some unit testing on some of the stuff using NUNit.
I'm having problems with a test method. The test method is as follows:
<br />
[Test]<br />
public void TestGetBlacklistByGirl()<br />
{<br />
List<string> list = new List<string>();<br />
list.Add("bing");<br />
list.Add("ht7");<br />
list.Add("rohde"); <br />
BlacklistDetails testObject = new BlacklistDetails(12, list);<br />
<br />
BlacklistDetails returnObject = BlacklistProvider.Instance.GetBlacklistByGirl(12); <br />
<br />
<br />
}<br />
Even though the Assert is commented out, NUnit reports an error at the line above - specifically with the Instance property which is:
<br />
static public BlacklistProvider Instance<br />
{<br />
get<br />
{<br />
if (instance == null)<br />
{<br />
instance = (BlacklistProvider)Activator.CreateInstance(<br />
Type.GetType(RSDConfiguration.BlacklistProvider));<br />
}<br />
return instance;<br />
}<br />
}<br />
When using the method outside NUnit it works as expected, but NUnit has a problem with it. I have no idea why NUnit complaints about it -- it's just a normal property, and it works fine.
Any ideas?
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
What error is it throwing out?
I'm not really sure but it could be that NUnit doesn't find some files. I had something similar when NUnit didn't find some configuration file. To test this just copy everything needed into the bin folder of NUnit. If it works afterwards you will have to find out which file is the problem and try to work around it (copying all files to the NUnit directory shouldn't be your long term solution ).
Robert
|
|
|
|
|
Hi Robert Rohde (nice surname you've got there )
Yup, that was the problem.
My web.config was the problem. NUnit couldn't find it. Anyway, I've fixed it now. Thanks for the reply
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
if i try...
ArrayList List=new ArrayList();
int i=0;
while(true)
{
List.Add(i);
i++;
}
When does the ArrayList crash? or it's never happened?
|
|
|
|
|
Provided there is no limit placed by the programmer on the ArrayList size then - since ArrayLists hold objects (value types are boxed) - the capacity of your ArrayList is governed by the size and number of objects you are holding, which in turn is governed by the heap size of your computer.
--
Cheers,
Gary
http://www.garyshort.org
|
|
|
|
|
The limits are int.MaxValue items or when you get an OutOfMemory exception, whichever comes first.
|
|
|
|
|
I've a project about socket and have some trouble....
I've create a serverSocket on port 80 of a server : (IPserver,80)
And then create a clientSocket on port 80 of some clients: (IPclients,80)
So i need a code to do
First I've created a serverSocket and listening communicate from clientSocket (done)
Second I need a code on clientSocket to do
0. Create clientSocket
1. Connect to serverSocket
2. To do something..
3. Disconnect
4. Sleep and wait
5. Connect to serverSocket
6. To do something..
7. Disconnect
8. Destroy clientSocket
I don't know how to code method Create clientSocket, method Connect to serverSocket, method Disconnect.
Anyway thanks for your reply
Le Trung Hieu
|
|
|
|
|
You should start off by examining the System.Net namespace in the .Net framework. Then if you have a specific question post it here.
--
Cheers,
Gary
http://www.garyshort.org
|
|
|
|
|
Hi
create two ports which should be available in network
one is for listening and one is for recieving
that means listner port will be the receiver port in another side
and vice versa
then inside the listen method use the start method and send method
inside the reciever method use the start method and recieve method of socket
..after that use stop method or close method in connectin close
Hope u have got some fair idea from this.Lots of examples are their in code project...
Regards
DilipRam
|
|
|
|
|
Thanks for your help.
But I only use one port(80).
Le Trung Hieu
|
|
|
|
|
hi, does anyone know how to obtain text from an external application's editor. I've used some Pinvoke functions to obtain the main window handle, then enumChildWnd to find the relevant class handle that the editor derives from. Now my question is. now that I've got the handle.. what do i need to do to read the text from the editor. I'm not trying to get any Window handle by using the windowtext function.. Ideally i would want to read all text or be able to read by line where the caret is located. If anyone could point me in the right direction I would appreciate it.
The App I'm hooking into is SQL Server Management Studio, the editor used by SQmgntStudio is called VsTextEditorPane..
Regards
Izak Fick
|
|
|
|
|
Hello community,
I just wanted to give a feedback, regarding to my question some days ago:My Question from 14. Sept[^]
There I was facing a Win32Exception, "Error creating window handle".
At this place I want to thank mav.northwind[^] for his great help!
He pointed me to the "User32.dll" method "GetGuiResources" (msdn documentation[^]),
which was exactly what I was looking for.
[DllImport("User32")]
extern public static int GetGuiResources(IntPtr hProcess, int uiFlags);
This method is able to return two values as you can see:
0 - Count of GDI objects: Is the one you also can watch over the taskmanager.
1 - Count of USER objects: Is not neccessary equal to the GDI Objects
and AFAIK not visible in the taskmanager.
An example, how the counting works:
If you place a UserControl on a form
1) a naked UserControl: GDI +1; User +1
2) a UserControl which holds a "PictureBox": GDI +1; User +2
3) a UserControl which holds a "System.Drawing.Pen": GDI +2; User +1
4) 2) + 3): GDI +3; User +2, ???
sometimes it returns: GDI +2; User +2, which would be expected)
I knew that there is a limit set in the Registry for the GDI Handle Quota (GDIProcessHandleQuota),
and there I also found one for the User Handle Quota (UserProcessHandleQuota).
Path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
NOTE: This limits are System limits, not process limits. Was not correct (Thanks to Robert Rohde)
So what I first did was doubleing the values from 10000 to 20000.
And what happens was nothing, no effect!
After a research I than found this very helpfull article[^] from Kristan Kenney
He points out that there are maximum acceptable limits for both values:
GDI max= 16384
User max= 18000
If you set the value over the limits the system will not work proper any more.
So I now did set the limits correct and my project worked again.
Now I wanted to find out how close I could come to the limits,
with my project blowing up a little.
I then scanned over all processes and found out,
that my project still crashes when the UserProcessHandles were about 13500 systemwide.
After rereading the Article from Kristan Kenney, I found an additional Registry setting which he also modified.
Path: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems
Key : Windows
This holds a long string with a section called: "SharedSection=1024,3072,512"
He modifies the second value of thees three (on my test PC there were four) to: "SharedSection=1024,8192,512"
I found a little explaination what this value does, at the msdn support[^]
The second SharedSection value (3072) is the size of the desktop heap for each desktop that is associated with the "interactive" window station WinSta0.
User objects like hooks, menus, strings, and windows consume memory in this desktop heap.
It is unlikely that you would ever need to change this second SharedSection value.
After this modification I was no longer facing crashes.
I'm now going over all my UserControls to find out which one can be modified.
Like, not using a PictureBox and painting the Bitmap in the OnPaint method of the UserControl.
Status from today: -1100 UserProcessHandles!
Hope someone can profit from that information!
Please correct me or give additional information.
-- modified at 9:00 Wednesday 19th September, 2007
All the best,
Martin
|
|
|
|
|
Thanks for the information
Regards
DilipRam
|
|
|
|
|
You are wellcome
All the best,
Martin
|
|
|
|
|
Martin# wrote: NOTE: This limits are System limits, not process limits.
Are you sure about this one? Some time ago I was tracking down a leak of gdi handles and my app crashed when the number of gdi handles for it (watching the gdi handles column in the task manager) reached exactly 10000.
Robert
|
|
|
|
|
Hello Robert,
You are 100% write!
Changed it!
I think its only the "SharedSection" which is a system limit.
Thank you for the correction!
All the best,
Martin
|
|
|
|
|