|
the same code is working fine for me ..
but it would be good if u mention the line where it catches the error
sathy
|
|
|
|
|
imsathy wrote: it would be good if u mention the line where it catches the error
I did. Didn't you see the line with the comment?
// <- Object reference error occurs here
|
|
|
|
|
RobertF57 wrote: did. Didn't you see the line with the comment?
// <- Object reference error occurs here
the code execution comes in to catch block after the error occurs ...
what im asking u is at which point it catches the error
keep a break point in ur code and c where the try block catches error
sathy
|
|
|
|
|
You probably missed something in the label. What does the code for the label look like?
---
b { font-weight: normal; }
|
|
|
|
|
Does anyone have an example of how to persist the values from an enum into a
Checked Listbox in the Visual Studio property Grid? There is an excellent example on this site by Thierry Bouquain (http://www.codeproject.com/cs/miscctrl/flagseditor.asp) but it uses code in the client page to persist the values Checked Listbox/ Enum values. I want mine to work more like third party components I have seen wqith no code in the client form required to persist the values. I have looked around and I think I need to use a TypeConverter to convert the selections to a pipe delimited string and stored in the designer. Getting the typeconverter to work has been complicated as I do not have a lot of experience with CodeDom / Reflection.
|
|
|
|
|
I am having a weird problem adding new objects to the directory server. I am logged in using the Manager account, so I have r/w access to everything. Here's how I add an object:
DirectoryEntry de = configuration.Bind(); // <- this works fine, I can read everything.
DirectoryEntry newEntry = de.Children.Add("cn=John Doe", "inetOrgPerson");
newEntry.Properties["sn"].Value = "Doe";
newEntry.Properties["givenName"].Value = "John";
newEntry.CommitChanges(); // <- this is where the exception is thrown.
System.Runtime.InteropServices.COMException (0x80072037): There is a naming violation.
at System.DirectoryServices.Interop.IAds.SetInfo()
at System.DirectoryServices.DirectoryEntry.CommitChanges()
at HMSImport.MainForm.menuItem3_Click(Object sender, EventArgs e) in c:\documents and settings\jd\my documents\visual studio projects\hmsimport\mainform.cs:line 255
Does anyone have a clue as what it could be?
I am running openldap-2.2.9 as the directory server.
|
|
|
|
|
Hi Jan,
I dont think you should do like this:
newEntry.Properties["sn"].Value = "Doe";
newEntry.Properties["givenName"].Value = "John";
rather use Add instead of Value this it should work
newEntry.Properties["sn"].Add = "Doe";
newEntry.Properties["givenName"].Add = "John";
I hope it helps
Osama Mirza
|
|
|
|
|
I am trying to achieve the following:
I start with two class library projects, e.g. phlib/phtree/phtree.sln and phlib/phmatrix/phmatrix.sln. Both have sub projects with examples, Q&D tests and unit tests.
I want to create a "main" class library project (phlib/phlib.sln), that references the relevant sources from the sub folders (but excludes the helper projects code)
is that even possible? C# (at least C# express) seems to always include all files. When I do "Add existing item", the file gets copied into the phlib project folder.
Some of us walk the memory lane, others plummet into a rabbit hole
Tree<t> in C# || Fold With Us! || sighist
|
|
|
|
|
Private Sub Socket_DataArrival(ByVal eventSender As System.Object, ByVal eventArgs As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles Socket.DataArrival
I have this already put into my Constructor
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
socket.dataarrival += new EventHandler(Socket_DataArrival);
Do i need to use the AxMSWinsockLib ?? because i'm not sure what goes in the Code Below here
private void socket.dataarrival(object sender, // Dont know what is suppose to be in this part)
Thxs in Advance..
-- modified at 17:55 Thursday 2nd February, 2006
|
|
|
|
|
I want to create a virtual serial port from my program, so I can send out serial data. I want my program to simulate an actual physical device, such as a GPS or Gyro, for testing purposes. I have seen many comercial programs that create two virual ports, and connect them, but I want just my program to expose itself as a serial port.
Ross King
------------------------
"Beer. Not just for breakfast anymore"
|
|
|
|
|
|
|
I'm currently having a problem, i hope one (or more) of you can help me out.
I have an application that loads DLL's from a directory in a seperate AppDomain. After that it gets the functions i want out of it using the System.Delegate class. So far so good. The functions are proparly loaded etc etc.
The thing is, i can only call the functions from within that particular AppDomain. At least thats what i think the problem is. But i do not want that. I want to be able to define the functions that i need from outside the wrapper that loads the dll's. I can say which functions it needs to pass to me but i cant attach a delegate to it in order to invoke the function.
Since i think the story above might be a bit confusing i'll set up an example.
Example:
<br />
delegate int Foo ();<br />
delegate void Bar (int Foobar);<br />
<br />
dllWrapper Wrapper;<br />
<br />
Wrapper.INeed("Foo_Inside_DLL", typeof(Foo));<br />
Wrapper.INeed("Bar_Inside_DLL", typeof(Bar));<br />
<br />
FunctionList myFunctions = Wrapper.LoadAll("plugins\\");<br />
<br />
<br />
Function FooFuntion = myFunctions.Find("Foo_Inside_DLL");<br />
<br />
((Foo)FooFunction.Delegate)();<br />
<br />
<br />
|
|
|
|
|
|
ahhh, never knew it would be that simple!
thanks, you're a life saver!
Edit (for those who want to know):
when you have functions in a seperate AppDomain you can _not_ call them from any other domain directly. What you can do is create a method in the class that contains the function that does a DynamicInvoke()
so in my case it was as simple as this:
<br />
FooFunction.Invoke(null);<br />
<br />
public object Invoke (params object[] args)<br />
{<br />
this.Delegate.DynamicInvoke(args);<br />
}<br />
and thats it, it works brilliantly!
-- modified at 18:14 Thursday 2nd February, 2006
|
|
|
|
|
Is there a simple way to do this? I've been working on an app with a gui (mostly because it's easier to test) because I know someone who said it was easy to turn an app into a service once you had it tested the way you want. He did it in VB.Net, though and I'm no longer in touch with him. As a service, it really doesn''t need the GUI, but I'd rather do it this way and not let the form show than copy/pasting all the code and getting rid of all the form-specific stuff.
My articles
BlackDice
|
|
|
|
|
Your form contains user interaction elements -- such as buttons / menus / textboxes etc. For service, you need single starting point for the thread.
- Malhar
|
|
|
|
|
that sounds like Chinese Algebra to me. wtf???
My articles
BlackDice
|
|
|
|
|
BlackDice wrote: that sounds like Chinese Algebra to me
I think I might know what he means.
I think he is trying to say that a service has a single starting point and has no user interaction. In otherwords, it starts and keeps on going until it is shutdown with no user interaction - unlike a GUI which starts and waits for user interaction before doing anything.
In other words, if your GUI has more than a single "Go" button, and your code interacts with the GUI in any way after that then it will need some work to get it to work as a service.
If your GUI is just using the textboxes and so on to set values for various methods to test one small area of processing, but the whole still works like a service, then there shouldn't be too many problems.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Ok. I've also looked at your post about the nUnit method. that sounds ok. But keeping to what you said in this post I'm replying to, that's all that's on the form is an exit button. It actually starts running once the form starts running. the only thing on the form is a listbox that shows trace statements; this would be written to a log file instead.
It let me add a form to the project, so I copied/pasted all my code into that form. I have the service compiling now, but I still need to add the setup stuff to it. I don't want the form to actually show though. Should I just hide it, or is there also a better way?
My articles
BlackDice
|
|
|
|
|
BlackDice wrote: It let me add a form to the project, so I copied/pasted all my code into that form
You should have no logic on your form at all - Even for a GUI application. The form class is there to process GUI events. The Business logic should all happen in a separate class.
It looks like you have some refactoring to do. As you don't have a complex GUI it should be fairly simple to extract all that logic to a separate class.
Don't ask about "hiding" the form. It's just wrong and would probably take as much time to figure out how to hide a form in a service as it would to refactor your code properly. Believe me, you don't want the maintenance nightmare this could very easily become.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Service and UI programs are meant for different things! Turning latter into the former is the real WTF!
Sample template for your service...
namespace MyNamespace<br />
{<br />
public class MyService : System.ServiceProcess.ServiceBase<br />
{<br />
private System.Timers.Timer timer1;<br />
private System.ComponentModel.Container components = null;<br />
<br />
public MyService()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
static void Main()<br />
{<br />
System.ServiceProcess.ServiceBase[] ServicesToRun;<br />
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new MyService() };<br />
System.ServiceProcess.ServiceBase.Run(ServicesToRun);<br />
}<br />
<br />
private void InitializeComponent()<br />
{<br />
this.timer1 = new System.Timers.Timer();<br />
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();<br />
this.timer1.Interval = 500;<br />
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);<br />
this.ServiceName = "MyService";<br />
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
protected override void OnStart(string[] args)<br />
{<br />
this.Initialize();<br />
}<br />
<br />
private void Initialize()<br />
{<br />
this.IsReady = true;<br />
this.timer1.Start();<br />
this.timer1.Enabled=true;<br />
}<br />
protected override void OnStop()<br />
{<br />
this.IsReady = false;<br />
this.timer1.Stop();<br />
this.timer1.Enabled=false;<br />
}<br />
public static DoSomethingAtSomeInterval(params object[] params)<br />
{<br />
}<br />
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)<br />
{<br />
if (!IsReady)<br />
{<br />
return;<br />
}<br />
else<br />
{<br />
IsReady = false;<br />
try<br />
{<br />
}<br />
catch (Exception ex2)<br />
{<br />
}<br />
IsReady = true;<br />
}<br />
}<br />
}<br />
<br />
<br />
[RunInstaller(true)]<br />
public class ProjectInstaller : System.Configuration.Install.Installer<br />
{<br />
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;<br />
private System.ServiceProcess.ServiceInstaller serviceInstaller1;<br />
private System.ComponentModel.Container components = null;<br />
<br />
public ProjectInstaller()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if(components != null)<br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
<br />
#region Component Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();<br />
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();<br />
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;<br />
this.serviceProcessInstaller1.Password = null;<br />
this.serviceProcessInstaller1.Username = null;<br />
this.serviceInstaller1.DisplayName = "[%FunctionName%]Service";<br />
this.serviceInstaller1.ServiceName = "[%FunctionName%]Service";<br />
this.Installers.AddRange(new System.Configuration.Install.Installer[] {<br />
this.serviceProcessInstaller1,<br />
this.serviceInstaller1});<br />
<br />
}<br />
#endregion<br />
}<br />
}
|
|
|
|
|
I wasn't saying wtf because you said something crazy or anything like that. I said that just because your reply went over my head. No sarcasm/disrespect intended. I do thank you for your input. however, I understand what you're saying now, but as I responded in my post to Colin, I don't actually NEED the gui; it was just easier to use a gui while I was building the app.
My articles
BlackDice
|
|
|
|
|
BlackDice wrote: I've been working on an app with a gui (mostly because it's easier to test) because I know someone who said it was easy to turn an app into a service once you had it tested the way you want.
Personally, I would have used something like NUnit[^]
I would have set the solution up as follows:
Solution
-- Service Bootstrap Assembly
-- NUnit Test Assembly
-- Service logic
The Service Logic project would contain all the code that the service uses. It would have zero dependancy on either of the other two projects - If it suddenly does need a dependancy the compiler will warn me about it and I know I've coded something wrong.
The NUnit Test Assembly (which is roughly equivalent to your GUI code) contains all the tests and is dependant on the Service Logic project (because that it what it is testing).
The Service Bootstrap is the EXE that actually runs as a service, but it has very little code as all it does is access the code in the Service Logic project. Again, this project is dependant on the Service logic assembly.
This keeps all the code nicely separated to when it comes time to deploy it you can just grab the bootstrap and the logic assemblies.
So, back to your problem, the best way to do this would be to extract the GUI from the service code and try and put something together that resembles the above - otherwise you are going to create lots of problems for yourself in the future.
BlackDice wrote: He did it in VB.Net, though and I'm no longer in touch with him.
Just as well. You you were I'd tell you to tell him that I think his solution is crazy and introduces lots of problems into the project that you are now having to resolve.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
I've done it the other way, using reflection on a service project to run it from the command line or a gui to make it easier to debug.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|