|
I've found a way of doing it, but it involves a COM interface. If there's a non-COM way, I'd love to hear about it....
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
What do you mean by "but if I try to use it, a new folder is created on the desktop"? Are you trying to access a folder shortcut? Can you explain it a little more?
It seems you've solved the problem via COM but here is another solution via Com Interop to Access the Windows Scripting Object. Maybe useful for a clear solution:
http://www.knowdotnet.com/articles/createshortcutondesktop.html[^]
|
|
|
|
|
(plz i need help, to make apper the bmp image as a pixles by c#
|
|
|
|
|
Wow - you do need help.
Image.FromFile
DrawImage
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
MSDN as usual sucks on documenting this, and most threads contain only partial code. I'm trying to create a windows service that allows anyone to call its "bool HelloWorld(string sSayCheese)" method via remoting.
The consumer of this method will be an asp.net page, but for now can be anything including a console app.
I have created many Windows services, so this is not the problem. The service is running fine, but I can't get it to allow others to call its public methods remotely.
Any help would be greatly appreciated for myself and the other devs in the office.
Thanks!
|
|
|
|
|
I usually put all my objects offering remote calls in a class library project. Then I can debug them by hosting them from a console application. As soon as they are debugged, I put the remoting configuration code in the service OnStart and the system.runtime.remoting section of the config file in the service config file. Either way, the startup code is the same whether it is in the Service OnStart or in a console app main().
The hardest part of your problem is consuming the remote objects from a web app; you must put the client configuration code in the Global.asax code behind file in the Application_Start method.
There are many people here who can answer your questions if you can make them specific enough. Are you having trouble with the remoting part, or is it that you don't know about Global.asax Application_Start? Give us some info and we can help.
|
|
|
|
|
The problem is in the remoting portion of the service itself.
The service looks like:
<br />
public class MyService : System.ServiceProcess.ServiceBase<br />
{<br />
private m_sString = "hello";<br />
...<br />
protected override void OnStart(string[] args)<br />
{<br />
RemotingConfiguration.Configure("RemotingServer.Config");<br />
}<br />
...<br />
public string StringFunction()<br />
{<br />
return m_sString;<br />
}<br />
...<br />
}<br />
And uses the following RemotingServer.config:
<br />
<configuration><br />
<system.runtime.remoting><br />
<application><br />
<service><br />
<wellknown <br />
mode="SingleCall" <br />
type="MyService,Tools.MyService" <br />
objectUri="MyService.rem"<br />
/><br />
</service><br />
<channels><br />
<channel ref="http" port="8500"/><br />
</channels><br />
</application><br />
</system.runtime.remoting><br />
</configuration><br />
The client looks like this:
<br />
MyService remoteObject = (MyService) Activator.GetObject(typeof(MyService), "http://localhost:8500/RemotingClient.rem");<br />
string sRetVal = remoteObject.StringFunction();<br />
The client RemotingClient.rem file looks like:
<br />
<configuration><br />
<system.runtime.remoting><br />
<application><br />
<client><br />
<wellknown <br />
type="MyService, Tools.MyService"<br />
url="http://localhost:8500/MyService.rem"<br />
/><br />
</client><br />
</application><br />
</system.runtime.remoting><br />
</configuration><br />
The error I receive is:
<br />
An unhandled exception of type 'System.Net.WebException' occurred in mscorlib.dll<br />
<br />
Additional information: The underlying connection was closed: Unable to connect to the remote server.<br />
The client code is sitting in an console app.
The service starts and reports it is running correctly. It is compiled as a DLL.
|
|
|
|
|
I am sorry I have not replied quickly. There are several problems to consider in the approach you have. You can't remote your whole service like you are trying to do. Instead, put your code in a class (preferably in a new class library project). The class must inherit from MarshalByRefObject to be remoted. Also, the "type" attribute in your config files should be in the form type="namespace.class,assemblyname". It looks like you have it backwards.
Also, when you write the client app, you can add a reference to your remote class, but is generally looked upon as bad practice. It will work though for learning about remoting. After you become more comfortable, there are other ways of referencing your remote objects in the client such as implementing an interface in the remote code, and only referring to the interface in the client code. There are also ways to make a meta data assembly using soapsuds to extract the definitions from the remote object, then compiling an assembly using the output from soapsuds. For now, just keep that in the back of your mind to explore after you get romoting to work in the most simple case.
1. Make a new class library project (call it HelloWorld or something).
a. Add a Class called HelloWorldInfo or something.
1. Make sure it inherits from MarshalByRefObject
2. Make a console project to act as a test server (call it MyServer).
a. Add a reference in MyServer to HelloWorld.
b. Add a config file to MyServer and add the remoting config to it.
c. In Main(), call the remoting configuration, and then wait for a keypress.
3. Make a console project to act as a client to the server.
a. Add a reference to HelloWorld (this is not good practice, but will serve as a simple way during learning).
b. Add a config file and put the client remoting config in it.
c. In Main(), call the remoting configuration, then call any methods you want and output the results to the console.
4. Debug the server by starting it in Visual Studio
a. Open a command prompt and type "netstat -a"
b. look in the list output from netstat for the port you have assigned to your remote object. You should see your computer listening on that port.
5. Open your client in another copy of Visual Studio and start it for debugging.
a. You can now step through your code in debug mode, and even step into the server code. This makes debugging much easier.
6. Once the server code is fully debugged, Make a new windows service project.
a. Add a reference to HelloWorld.
b. Put the remoting configuration code in the OnStart of your service.
c. Add an installer to your service.
d. Add a setup project to install your service.
After you get comfortable with remoting, be sure to go back and learn how to reference remote classes in the remote client without deploying the server code to the client (so it by implementing interfaces, or compiling metadata-only assemblies).
|
|
|
|
|
Hi,
I had trouble about flickering effect on an MDI form. I'd built my own control, which is moveable by draging, and also overrided the paint event. It was very well in a normal form but unfortunately disappeared in MDI form. Even some of the codes provided here have the same problem. What is handle the MDI form painting event? Is it different from the normal one? And how could I fix such a problem?
Thanks in advance.
|
|
|
|
|
There's nothing different about an MDI Form being painted. There is no seperate event for painting either.
Is your control on the MDI Parent form? Did you know that there is a MDIClient control on the Parent form? Is you control in the Controls collection of the MDIParent or the MDIClient? If it's the MDIParent, your control is probably being painted over by the MDIClient area control.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Is there a way to import regirtry files within C#?
this way i could update some settings myself, and then in C# just open up the registry to the necessary folder and import the files. This would save alot of messing around and i would be able to use the peice of code again.
Any ideas?
|
|
|
|
|
This is an example of a file exported from regedit:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ppt]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ppt\OpenWithProgids]
"PowerPoint.Show.8"=hex(0):
this is just for the file extension .ppt
Is there any way that i can use this?
|
|
|
|
|
I am not sure how this is done. I have been doing some searching and reading and I can't seem to get this to work. I am really bad with terminology, but if someone could point me in the right direction I would bw greatful...
Thanks,
Eric Garcia
|
|
|
|
|
Ok, just pass the textbox instance to the other class's constructor or a method in that class. For instance,
class ClassWithTextBox
{
private TextBox myTextBox = new TextBox();
ClassWithoutTextBox classWithout = new ClassWithoutTextBox();
classWithout.ChangeTextboxColor(myTextBox);
}
class ClassWithoutTextBox
{
void ChangeTextboxColor(TextBox textBoxToModify)
{
textBoxToModify.BackColor = Color.Red;
}
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Hallelujah! It's Ken Jennings!
Judah Himango
|
|
|
|
|
Here is a better explination...
private void FollowLink(object parameters)
{
CMTag_Spider.SpiderForm spiderform;
//Other code here
spiderform.txtOuput.AppendText("/tLink:" + link.AbsolutePath);
//Other code here
}
compiler:
Use of unassigned local variable 'spiderform'(CS0165)
The situation I have is that I am using a c# webspider class and calling it from a form I named SpiderForm. Because of the way the Spider was coded I am not sure that I want to make too many changed to it.
I thought there was a way to declare a form and then set that to the active form and then as long as the textbox was public I could access it.
What I am not sure about is how to assign the spiderform variable...
Thanks for the help,
|
|
|
|
|
Assign it by taking an instance of the class that actually contains the spiderform object, then accessing that variable (provided it's public). Another option is to make the variable static and public, then you don't need an instance of the class to access it.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Hallelujah! It's Ken Jennings!
Judah Himango
|
|
|
|
|
I have a program I am writing for my own personl use that takes an XML file and interprets it into a treeview, then if a secion is clicked it shows the information between the tags in a textbox. The problem im having is with this peice of code.
XmlTextReader document = initializeXmlReader();
while((document.Name != e.Node.Tag.ToString()) && (document.GetAttribute("Name")!= e.Node.Text))
{
document.Read();
}
All the tree nodes are made up of the elemets attributes, this code works partially to go through the document and find if the right attribute, but sometimes it returns null, and does not display the next catagory's text.
Here is some sample XML.
<?xml version="1.0" encoding="utf-8" ?>
<Main Name="Desktop Sidebar Help">
<![CDATA[ TEST TEST TEST ]]>
<Key_Cat Name="Overview">
<Sub_Topic Name="Context Menu">TestTestTest</Sub_Topic>
<Sub_Topic Name="Options"></Sub_Topic>
</Key_Cat>
<Key_Cat Name="Basic Panels">
<Sub_Cat Name="Communication">
<Key_Topic Name="Mail Checker Panel">
</Key_Topic>
<Key_Topic Name="Messenger Panel">
</Key_Topic>
<Key_Topic Name="Miranda IM">
</Key_Topic>
</Sub_Cat>
<Sub_Cat Name="Groups Panels">
<Key_Topic Name="Stack Group">
</Key_Topic>
<Key_Topic Name="Tile Group">
</Key_Topic>
</Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="News"></Sub_Cat>
<Sub_Cat Name="Outlook Panels"></Sub_Cat>
<Sub_Cat Name="System"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="3rd Party Panels">
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="Skin Development">
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="Plugin Development">
<Sub_Cat Name="DS SDK Documentation Forum - About"></Sub_Cat>
<Sub_Cat Name="Creating/Adding a Panel">
<Key_Topic Name="Creating an Empty Panel"></Key_Topic>
<Key_Topic Name="Adding Your Panel to Desktop Sidebar">trdtfgrgbergbergbergber</Key_Topic>
</Sub_Cat>
<Sub_Cat Name="Creating a Panel Installation File "></Sub_Cat>
<Sub_Cat Name="Publishing Your Panel"></Sub_Cat>
<Sub_Cat Name="Using Components"></Sub_Cat>
<Sub_Cat Name="Reference"></Sub_Cat>
<Sub_Cat Name="FAQ"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="FAQ">
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="Universal Help Engine">
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="About Universal Help Engine">
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media">TESTTESTTEST</Sub_Cat>
</Key_Cat>
<Location ID="http://"><Location>
</Main>
I've been testing it by just clicking the first few treenodes that have a different attribute. But most of the time only one or two will work before it is just stays on the same thing for anything else I click. This is really bothering me. I edited out the text that was inbetween the tags, for length problems in this posting.
Sample of what its doing.
Tree
Desktop Sidebar
--OverView
---Context
---Options
--BasicPanels
---Communication
----Mail Checker Panel
----Messanger Panel
----Miranda IM
and so on
When I click mail checker panel for instance, it will show up right. But then if I click messanger Panel, it will show up with Main Check Panels text instead of Messanger Panels Text, upon debugging I noticed that getattribute is returnning null sometimes, I beleive this is the problem. The text between the tags will, contain HTML which is parsed by the textbox/web browser i've incorpertaited.
Any help would be much apperiated. Also if more code is needed I can post it.
|
|
|
|
|
In general when I know exactly the keywords(about 300) I want to find should I use something like:
1)Regex(@"if|do|for|while|int|Int32|Int64...(about 300)") or
2)Regex(@"[_A-Za-z]+[A-Za-z]\w*] and follows searching in a hashtable?
|
|
|
|
|
Option 2 would be preferable, speed and maintainability are the biggest benefits.
Option 1 is simply out of the question. That's just a nightmare waiting to bite you.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
I have been banging my head against the wall on this for a couple of hours now.
I work with SQL usually and have that down to an artform, but i am working on a project that requires me to insert info into an access db, and i am trying like hell just to get a simple statement to work, but i cant find a hting in msdn or on the internet. Any suggestions?
______________________
Yes, I am the highly suggestable type.
|
|
|
|
|
What's the statement your trying to get working?
Keep in mind that Jet doesn't support named parameters, but it does support parameters. You just have to supply them in the exact same order that they appear in your SQL statement. Also, Jet doesn't support the full range of SQL syntax that SQL Server does.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
here is the code I am attempting to use:
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + DS + ";";<br />
string comma = "INSERT INTO comments (page,who,comment,email) VALUES (" + page + "," + name + "," + comments + "," + mail + ")";<br />
OleDbConnection con = new OleDbConnection(strConn);<br />
OleDbDataAdapter da = new OleDbDataAdapter(comma,con);<br />
OleDbCommand cmd;<br />
cmd = new OleDbCommand(comma, con);<br />
<br />
con.Open();<br />
cmd.ExecuteNonQuery();<br />
con.Close();
______________________
Yes, I am the highly suggestable type.
|
|
|
|
|
Looking at your code I can't see why it doesnt work.
I do have a couple of suggestions that might help.
1. The OleDbDataAdapter is not required to execute a simple command it is only required when performing operations on datsets.
2. I would use parameters instead of hard coding the values into your command string, problems will occur if you have special characters in the varaiables such as quota marks. To do this the code will look something like below. (NOTE: You need to set the appropriate varaibale types for each parameter, I have guessed at what they might be)
3. I would recommend enclosing field names in square brackets as some words are reserved, see below.
string comma = "INSERT INTO comments([page],[who],[comment],[email]) VALUES (paramPage, paramName, paramComment, paramMail);"
OleDbConnection con = new OleDbConnection(strConn);
OleDbCommand cmd = new OleDbCommand(comma, con);
cmd.Parameters.Add("paramPage", OleDbType.Integer).Value = page;
cmd.Parameters.Add("paramName", OleDbType.VarWChar).Value = name;
cmd.Parameters.Add("paramComment", OleDbType.VarWChar).Value = comments;
cmd.Parameters.Add("paramMail", OleDbType.VarWChar).Value = mail;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
|
|
|
|
|
use single quotes :
VALUES ('" + page + "','" + name + "','" + comments + "','" + mail + "')";
|
|
|
|