|
So you mean the automatically-generated code (by Visual Studio) is exposed automatically, and you want to hide this, and only expose facade class (that you made) to the client?
In the DLL wrapper project, go to the Solution Explorer window, in the top click second icon from the left (It says "Shows All Files"). After that, you should be able to see in your Web References folder, you WS (which was one node only), now can be expanded. Try to expand it, and expand Reference.map, and you should file Reference.cs
This cs file contains WS operation that we've been talking about. If you don't want to expose it, just change all class declaration here from public into internal . Therefore, only class in this wrapper DLL (in the same assembly) can access this.
"If Mohammed won't go to the mountain, then the mountain must go to Mohammed" - Gil Grissom, CSI
|
|
|
|
|
Looks like that might do it, thanks!
|
|
|
|
|
Hey all. I'm new @ C# and I am trying to make a small application on my PC. Basically the functionality of this is to allow incoming TCP connections and pass them through to the COM port and vice versa. (So I can connect home and tell my TV to tune to a channel and start recording).
The parts function perfectly independently. I have a main class that spawns a new thread. That new thread opens up a SerialPort connection, and basically sits and waits for commands to be heard from the serialport (for my box to talk back to me and tell it that it did what I wanted it to do). When I do things on the TV, it talks to the COM port, and when I send it commands the TV receives them and does the command, so that part works fine.
Now the second part is my TCP/IP connection. I am using TcpServiceProvider to make this happen. It's listening on port 15555 for commands. When I run this (with MessageBox windows), when I telnet into it and send commands, it receives them, and when I send it commands it sees them just fine.
So, now my problem is tying the two of these classes together. Basically in my main class, I want to open the SerialPort connection and keep it open. I want the TCP server class to talk to the COM port through that variable that I created in the main class.
What I've done to try to accomplish this is in my TCP server class, I created a private variable like so:
private SerialPort _sp;
I created a method too:
public void SetSPVariable(SerialPort sp)
{
_sp = sp;
// for debug, I did this
_sp.Write("TEST");
}
public void TestComs()
{
_sp.Write("TESTING NUMBER TWO"); // this never works
}
It works fine when I call the SetSPVariable method. Now there are other methods within my TCP server class that need to talk to the serial port too (which is why I opted for the private variable within the class). Those other classes can not talk to it whatsoever. It just doesn't work and I can't figure out why. I've tried to pass by reference, but that didn't work either. So basically, in my main class I do something like this:
sp.Open(....);
sp.Write("This works fine");
TCPServerVariable.SetSPVariable(sp);
// at this point in time, you can see the TEST message coming out the COM port from within the
// TCPServer class
TCPServerVariable.TestComs();
// You never see the communication coming from there.
I know that the serial port is still being held open by the main class because when I send commands from another laptop via NULL MODEM cable they show up in the debug message.
I tried passing by reference, but that didn't seem to work. It appears that when the method is finished it somehow is messing up the local class _sp variable. I don't know why. Like I said I'm new to it, and it is probably something really silly.
I'd really appreciate any help on the matter. I've read through for three hours trying to figure this out, and I figure that it's about time to ask for help on the matter.
Thanks greatly
SHULTAS
|
|
|
|
|
I would try running it in a debugger and see what the state of the socket is when you hit the TestComs method. Is it still connected/opened? Or did it get closed somehow?
Like the Stefan mentioned, it could be that one thread is setting the socket while another thread is trying to use it, which might cause a problem if the conditions are right.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I don't think there is something wrong with passing the serial port object. More likely there may be some threading issues or similar.
Does the following work?
public void SetSPVariable(SerialPort sp)
{
_sp = sp;
_sp.Write("TEST");
_sp.Write("TEST2");
}
Is there some code between calls to SetSPVariable and TestComs?
www.troschuetz.de
|
|
|
|
|
Thanks for the quick reply, I appreciate it.
Yes, the multiple _sp.Write()'s work just fine. The flow of the program is as such: Program Loads. Main Class creates a new thread (the thread is another class). The thread then creates an initializes a SerialPort variable, and opens the COM PORT. Next, that thread creates the Provider (TcpServiceProvider) and starts the server. (It has an AsyncCallBack that calls a method within the TCPServer class when data is received from the TCP port). After it does that stuff, I basically have a while (running) { } loop in there that just keeps it running until you press the close button. (I put code in there to write to a file while it was running, and it runs non-stop). While it is running, it is basically calling SerialPort.ReadExisting() to get what's in the buffer (if anything). It just keeps looping and checking the incoming com port buffer for text. If it sees any text, that thread calls the TCPServer class "SendString" method to send out the string. That works totally fine, when I send data into the COM port on my PC, it immediately shows up in the telnet window. When I type in the telnet window, a message box pops up saying "I received this text: " and the text, directly after the message box text it does the _sp.Write() method, but nothing ever shows up on the COM port at that point. But, if I go ahead and type some more stuff on the COM port after that, it shows up in the telnet window (so that is telling me that the COM port is being held open). The odd thing is that no errors are thrown and no exceptions or program crashes are happening and I'm totally stumped at this point.
Again, thanks for the help, it is gladly accepted
*** Addendum: I just loaded this up in debugger as the other poster had mentioned, and I get the following error:
A first chance exception of type 'System.NullReferenceException' occurred in TcpServerDemo.exe
So it does appear that at some point that local pointer:
_sp = sp;
is getting wiped out for some reason?
|
|
|
|
|
Seems like a really weird problem you're having there. I can't image that the private variable is wiped out for some mysterical reason. At least it would be the first time i hear of something like this. Are you sure the exception is thrown when you access the _sp variable? Do you have any code that changes this variable other than the Set function that may be executed for some reason? I think the best would be adding a breakpoint in the Write method of your serial port and check step by step what goes wrong. (as mentioned)
www.troschuetz.de
|
|
|
|
|
Does anybody know's a free obfuscator for .net? One that can do the job and not mess the code up...
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
|
Thank you.
When I mentioned about messing up the code I ment messing with the functionality too - I used a not so famous obfuscator and it maked my assemblies to give errors at runtime (that without obfuscation from that application would not appear).
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Yeah, I hear you. My opinion of obfuscators is that they're a hack; they break functionality, especially in .NET remoting apps. I've yet to find one that really works on our large client/server app.
|
|
|
|
|
Like Judah said, the point of an obfuscator is to make the code harder to read by removing context (i.e. messing it up). The point being that it makes reversing engineering of your code harder. So for an obfuscator to do it's job it will need to mess around with the code.
|
|
|
|
|
I have a problem whith aplication on the server..this
server back me this message:
The server viewstate cache has timed out. The application was unable to successfully recover state. To address this exception, modify your web.config to use client-side viewstate caching, or to extend the server cache timeout value.
|
|
|
|
|
|
Hi friends
I want some help regarding Textbox editor like when we compose mail then it gets formatting (ex: Bold, Italic,Underline,spell check etc..).
In Web apllication (ASP.NET with C#).\
Thanking u,
Naren
please help me
|
|
|
|
|
I don't think there's anything like that out of the box. You may have to author something like this yourself or purchase a component that does this for you. But, I'm no ASP.NET exptert; perhaps this would best be answered in the appropriate forum[^].
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I need to have a database of all runned applications. I have a server - terminal, and other users log in terminal. I need to have a list of running applications, of its owners etc...
And of course I want to know how can I update my Database effectively!
Please help me...
P.S. Sorry of my bad English. It's not my native language!
|
|
|
|
|
|
Hi everyone,
I've got a problem and I can't solve it with anything! I have a button that when one clicks on it a groupbox is enabled showing a label with the value of a row which was random from a database. Then when one clicks the next button another question is random and displayed in the same label.Now I would like that after the user clicks the next button for ten times, it is disabled. How can I do this?
Thanks
|
|
|
|
|
Can you elaborate on the problem?
Is it disabling the button? Is it selecting random questions from a database? Is it keeping track of ten clicks?
Help us help you.
--
I've killed again, haven't I?
|
|
|
|
|
Yes a new question is random everytime I click the Next button. But it's not keeping track of the ten clicks that the user makes since I don't know how and at the moment the button is not disabled.
|
|
|
|
|
Create a variable, e.g. userClicks . Initialize it to 0. In your button's Click handler, increment the value of userClicks , and if it is 10, set the button's Enabled property to false .
--
I've killed again, haven't I?
|
|
|
|
|
Thank you, Thank you
I've done it
|
|
|
|
|
just use an INVISIBLE TextBox control to store the track and count of the clicks.
|
|
|
|
|
Hi Alee
It would be helpful if you told us whether this is a windows- or web application. But I guess you're talking about web.
You could store the number of times in ViewState (a hidden form field on the webpage)
Something along the lines of:
http://www.sweetsilence.dk/codeprojectprojects/limitedclicks/[^]
Here is the code below, also available at:
http://www.sweetsilence.dk/codeprojectprojects/limitedclicks/limitedclicks.zip[^]
--------------------------------------------------------------------------
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblQuote;
protected System.Web.UI.WebControls.Label lblNumberOfClicksLabel;
protected System.Web.UI.WebControls.Label lblNumberOfClicksValue;
protected System.Web.UI.WebControls.Button btnShowQuote;
protected int NumberOfClicks
{
get
{
if(this.ViewState["clicks"] == null)
return 0;
else
return (int)ViewState["clicks"];
}
set{this.ViewState["clicks"] = value;}
}
private void btnShowQuote_Click(object sender, System.EventArgs e)
{
if(this.NumberOfClicks < 10)
{
lblQuote.Text = GetQuote();
NumberOfClicks++;
}
else
{
lblQuote.Text = "[no more quotes for you!]";
lblQuote.ForeColor = Color.Red;
}
}
public string GetQuote()
{
if(this.NumberOfClicks % 2 == 0
return "Even is pretty good";
else
return "Odd is good too ; )";
}
private void WebForm1_PreRender(object sender, System.EventArgs e)
{
lblNumberOfClicksValue.Text = this.NumberOfClicks.ToString();
}
}
Three kinds of people in the world:
- Those who can count..
- Those who can't!
-- modified at 14:47 Thursday 6th April, 2006
|
|
|
|