|
Ah I knew I had done something more similar that this to exactly what you're asking before. Here it is:
private void LoadOptions()
{
string [] keys = new string[currentOptions.Keys.Count];
currentOptions.Keys.CopyTo( keys, 0 );
foreach( string optionName in keys )
{
System.Type optionType = currentOptions[optionName].GetType();
string iniSetting = GetSetting( optionName );
Array enumValues = Enum.GetValues( optionType );
foreach( object enumValue in enumValues )
{
if( enumValue.ToString() == iniSetting )
{
Utils.Trace(null,"Option {0} changed from {1} to {2}.", optionName,
currentOptions[optionName].ToString(), iniSetting );
currentOptions[optionName] = enumValue;
}
}
}
}
Matt Gerrans
|
|
|
|
|
Thanks for the responses. Itinka understands what I want to do. But how do I convert an integer value back into a FontStyle that I can pass to the Font class constructor?
Mark
|
|
|
|
|
I think I wrote:
(FontStyle)(int)
...just convert it (every enumeration member naturally has an index).
|
|
|
|
|
Hi All,
I have a WinForm that has a static panel on it. Everytime I go to add something to my WinForm the IDE is trying to outsmart me and keeps on deleting that static panel along with all the code for it. Is there a way to stop the IDE from doing this ?
-Pete
|
|
|
|
|
Once upon a time, I was working on custom Windows Forms Designer. It's based on some kind of "roundtrip", which parses your code into DOM tree and then recreates the code back. If you've written something what doesn't smell much good to parser, it may not create right representation in DOM and your code is lost.
This was a problem in VS .NET 2003, I don't know if it's better on new VS Beta, but I solve these problems creating regular panel in designer and then adding my own controls in constructor:
myControl.Parent = panel1;
And you can also learn how to work with IExtenderProvider.
I don't know if I helped you much.
|
|
|
|
|
how can i disable windows's hotkeys like:
alt+tab
cntrl+esc
windows key
etc... i dont need to disable control alt delete though.
|
|
|
|
|
I haven't actually tried this but in theory you could listen to KeyEvents and see what key combination has been pressed. If you pick up something that interests you can choose to act on it or ignore it.
|
|
|
|
|
Hi,
We've wrote an app that utilizes asynchronous sockets to collect real-time information and write it into the database. We are using a slightly modified version of this example: http://www.codeproject.com/csharp/socketsincs.asp for our socket component.
Our app works fine, we've been testing it for a week and a half now and it performs almost flawlessly. The problem is that we also need a windows service version of the app, we've completed the windows service a week ago but for some reason it won't work. I've tracked it down and it turns out the BeginConnect call does not work. It just won't connect to the server and therefore no socket is created.
m_sock.Blocking = false;
AsyncCallback _connect = new AsyncCallback(ConnectServer);
m_sock.BeginConnect( epServer, _connect, m_sock );
ConnectServer should return IAsyncResult ar from which we can derive a socket, however it does not work. BeginConnect call fails and service simply fails to establish a connection.
Now with the exception of couple of lines specific to the app, the code in the app and in the service is absolutely identical, yet the app works absolutely fine and the service does not. We have no idea what is wrong with the service, why it won't establish connection. We've tried running the service under the domain administrator account thinking it was security issue, but it still won't work.
Anyone has any idea what's wrong here? I'm at a complete loss, been searching google for several days now to no avail.
|
|
|
|
|
LOCAL SERVICE user account, which is the default for services, does not allow network access. Set your service to run under the NETWORK SERVICE account or ADMINISTRATOR.
|
|
|
|
|
We have already tried network service and domain administrator accounts. We just tried administrator and it still won't work...
|
|
|
|
|
Hello,
Is there a way of RowFilter the null columns?
Sort of:
dataview.RowFilter = "RevenueID = " + WHAT GOES IN HERE?
Thank you.
|
|
|
|
|
Try:
dataView.RowFilter = "Isnull(RevenuID, '*NULL*') = '*NULL*'";
the '*NULL*' is simply a replacement string. It can be anything you wouldn't find in the column.
|
|
|
|
|
I tried that before.
Unfortunatelly the RevenueID is an integer, so it gives me an exception that it can not perform an '=' operation on Int32 and String.
Don't know what to do.
Thank you
|
|
|
|
|
Hello,
Try To Use this:
dataview.RowFilter = "RevenueID IS NULL" if u need to view the null values
dataview.RowFilter = "RevenueID IS Not NULL" if u need to view the not null values
good luck.
|
|
|
|
|
Hi
I am trying to post some xml data to secured server https:// using HttpWebRequest of System.Xml class in c#. It works fine and get valid response from remote server 1st time when I post the request but in the subsequent request I get following exception of HttpWebRequest "The remote server returned an error 400 bad request " but if restart the application and try to send again it does not throw this exception.
Would much appreciate your help if anyone of you had encountered the same problem and resolved it.
Thanks in advance
Share knowledge to enhance your learning
|
|
|
|
|
Hello,
I have a table "LotYields", and I have a dataview.RowFilter on this table to display only certain rows depending on RevenueID (column in dataview).
However, I want to create a new record in the table, and RevenueID will be null, is there a way do Filter that row, and set the values to it's cells.
Thank you
|
|
|
|
|
Hi,
In c#. NET, why two dlls in two different projects
cannot refer to each other (causing circular dependencies when compiling) ?
What should I do if the two dll really need to refer
to each other ?
Thanks
|
|
|
|
|
One way to over come a circular reference is (if I may coin a new phrase) code triangulation.
Basically, what you want to do is create a third assembly with the "common" items you need to access stored with it (enums, methods, properties, etc). Then add that third assembly as a reference in the other two. That way the third assembly becomes an intermediate between the two.
In Assembly1:
private void Method1()<br />
{<br />
Assembly3 a3 = new Assembly3();<br />
a3.PropertyA = "Something";<br />
<br />
a3.Commit();<br />
}
In Assembly 3:
public void Commit()<br />
{<br />
Assembly2 a2 = new Assembly2();<br />
a2.DoSomeWork(this);<br />
}
In Assembly2:
public void DoSomeWork(Assembly3 a3)<br />
{<br />
<br />
Console.WriteLine(a3.PropertyA);<br />
<br />
}
Hope this helps. Let me know if you have questions
Peter Corcoran
peter@corcoranp.com
www.corcoranp.com
|
|
|
|
|
If you have circular dependencies, you really need to think about redesigning the code. Circular dependencies are a design flaw. I've never found one that I couldn't fix with a better design.
I'll give you an example: In our project, we have a number of custom controls.
One is a general control library that contains a collection of basic controls.
Another is a grid control which uses a number of controls from the general library.
A third is a library of less basic controls that tend to be composite controls of the general or grid control. It also contains things like our custom modal form class.
We ran into a problem where the grid needed to use the custom modal form to display grid configuration information. Obviously, this would have created a circular reference since the third library already has a dependency on the grid control. The solution was to make the custom form control a "general control", which in the end made more sense.
As the previous poster pointed out, the solution is often a third library.
|
|
|
|
|
I had a similar situation too.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hi,
How can I get the version number of the Setup (last item in the deployment-project property window)?
I would like to use this version # instead of the complex Application.ProductVersion #.
Thanks
Ariadne
|
|
|
|
|
Hi!
IIRC, there's the variable [ProductVersion] you can use, for example as argument to a custom action.
Regards,
mav
|
|
|
|
|
Hi Mav,
there's the variable [ProductVersion] you can use
does that mean, I have to export this variable at setup-time into eg. registry-entry and read that, if the user requests a about box?
Ok - good idea, but how to insert the [ProductVersion] in the Registry-key? What do I have to type in the value property of the registry settings property in the setup project?
Thanks
Ariadne
|
|
|
|
|
Doesn't simply setting the RegKey's value to [ProductVersion] work?
I guess Windows has to store this value somewhere in the registry as well, because you can look it up using the Software control panel, but I don't know where.
Regards,
mav
|
|
|
|
|
mav.northwind wrote:
Doesn't simply setting the RegKey's value to [ProductVersion] work?
No, unfortunatly not.
mav.northwind wrote:
guess Windows has to store this value somewhere in the registry as well, because you can look it up using the Software control panel, but I don't know where.
Yes, but it is a path like:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\<br />
CurrentVersion\Installer\UserData\S-1-5-18\<br />
Products\18BDC9716DDB9A34F877C4F67C64396B\InstallProperties
and that is IMHO too heavy to decode.
Now I'm just writing a little program, which increments the build No. each time a build a release version. (I have posted an article here in codeproject). This make more sense in my situation.
Thanks
Ariadne
|
|
|
|