|
Hi again Marc,
Marc Clifton wrote:
No wait--you want to supply the internal source obfuscated, but there are certain "public" unobfuscated classes and methods that are the interface points? Is that it?
It is exactly this! What is happening, with the tool that I am using: It is changing the names of the types, instead of changing implementation only.
However, when beginning to talk with you I went to test other tools (Salamander, for instance) and I noticed that work in the expected way.
It seems that am in the road. Thank you, again!
Marcelo Palladino
Brazil
|
|
|
|
|
Hi again, Marc!
Now I have the clearest subject in my mind. I want assemblies obsfucation but it would like the names of the members not to be altered by this process. That is possible?
Sincerely,
Marcelo Palladino
Brazil
|
|
|
|
|
Hey
If you have a .NET remote server and a client seperated by an shared assembly, is it the possible to test the connection.
I want to test the connection to the server to see if it is running before executing any of my remote methods on it.
When I'm using RemotingServices.Connect I will never get null in return, when using a shared assembly. I have also tried using Activator.GetObject, no luck.
Is there any way to see if there is a running server in the other end before executing methods?
|
|
|
|
|
I just read yesterday something about that the proxy won't actually finish the process of connecting to the server and loading the shared assembly until you actually reference it in a method call.
For example, I can create the channel, register it, and use Activator.GetObject without a single problem. Only when I make the function call do I get the following exception:
"No connection could be made because the target machine actively refused it"
So, maybe you can have a dummy "Test" method that you call and catch an exception on?
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Hi all,
I wrote a multi-thread application using sockets. But when i attempt to stop a thread, the thread is falling into "AbortRequested" state but never being aborted. Can anyone help me?
My code is below:
if ( this.m_ReceiveThread.IsAlive )
MessageBox.Show( "alive" );
MessageBox.Show( "State: " + this.m_ReceiveThread.ThreadState.ToString() );
if ( this.m_ReceiveThread != null )
{
for ( int i = 0; i <= 10; i++ )
{
try
{
this.m_ReceiveThread.Abort();
this.m_ReceiveThread.Join( 100 );
/*
!!!!!! it always says current state is AbortRequested !!!!!!
*/
MessageBox.Show( "m_ReceiveThread trying to abort. - " + i.ToString()
+ "\nCurrentState: " + this.m_ReceiveThead.ThreadState.ToString() );
}//End of try.
catch
{
}//End of catch.
if ( this.m_ReceiveThread.ThreadState == ThreadState.Aborted
|| this.m_ReceiveThread.ThreadState == ThreadState.Stopped )
{
MessageBox.Show( "m_ReceiveThread aborted." );
break;
}//End of if ( this.m_ReceiveThread.ThreadState == ThreadState.Aborted ).
}//End of for( int i = 0; i <= 10; i++ ).
}// End of if ( this.m_ReceiveThread != null ).
|
|
|
|
|
Thread.Abort:
Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread. Calling this method usually terminates the thread.
I like the word "usually".
Look at the example in MSDN. Are you catching all exceptions in the thread and not properly handling ThreadAbortException?
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
To add to what Marc said, take a look at this.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Kentamanos wrote:
To add to what Marc said, take a look at this.
A thread will not terminate correctly if some process
are still running (consuming) a protected ressource.
Ah yes! Excellent! I'm in the middle of working with some serial I/O code in C# that uses protected resources, and it's the wierdest thing to exit the application and still see the application running in the process list even after doing an abort on the receiver thread. Needless to say, I wasn't cleaning things up.
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Marc Clifton wrote:
some serial I/O code in C#
Marc...why aren't you just using the System.IO.Ports.SerialPort class?
When I can talk about 64 bit processors and attract girls with my computer not my car, I'll come out of the closet. Until that time...I'm like "What's the ENTER key?"
-Hockey on being a geek
|
|
|
|
|
Nice to know I'm on your "to read" list.
David Stone wrote:
Marc...why aren't you just using the System.IO.Ports.SerialPort class?
Because I'm not using Longhorn!
And, is there some reason they didn't inlude the parallel port in the Ports namespace? Oh yes, I forgot--Microsoft wishes the thing had never been invented!
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Marc Clifton wrote:
Nice to know I'm on your "to read" list.
Heh...I was just browsing through the forums.
Marc Clifton wrote:
Because I'm not using Longhorn!
Well...you don't have to use Longhorn. You could just use Whidbey.
When I can talk about 64 bit processors and attract girls with my computer not my car, I'll come out of the closet. Until that time...I'm like "What's the ENTER key?"
-Hockey on being a geek
|
|
|
|
|
|
how to draw a X coordinate with a series of datetime data?
my question is mainly how to deal with the datetime and how to draw?
Please give me a sample about it! Thanks a lot!
|
|
|
|
|
Drawing is handled in the OnPaint of a control. Use DataTime to work with data time data. If you want to draw text you use DrawString() method. Doc's here: [^]
Docs for Graphics class : [^]
|
|
|
|
|
Hi All,
how do we interact 2 way BETWEEN A COM COMPONENT[say written in MFC COM] and a simple java class/EJB component.
say i wish to call a method in the java class from the COM component.
From COM component ,i pass it a number,the java class/component must multily it by say 10 and return the result back to COM component.
Is it possible.
Both reside on same machine.
Thanking you..
Regards
God Is Great
|
|
|
|
|
Yes you can. See the JNI reference at http://java.sun.com[^]. Please do not continue this thread, though. This is the C# forum, not the MFC, COM, or Java forum.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the link..ur right,i should have posted it in the java or COM forum
Cheers..
God Is Great
|
|
|
|
|
Hi!
May be yo can help me with this problem: I need to create a new instance of class (DLL or Windows Class file) that part of the project in a separate thread. Then I need to communicate with that class by passing some varibales or calling function/methods in this class. So question is: How I can do that (with multythreading) ?
I appreciate if you write me some code too - thanks
"I have not failed.
I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
|
|
|
|
|
Jasper4C# wrote:
Then I need to communicate with that class by passing some varibales or calling function/methods in this class. So question is: How I can do that (with multythreading) ?
That's bit vague, so here goes:
1. look at the "lock" keyword in C# for preventing multiple threads from writing to a variable at the same time.
2. Look at the Mutex class for synchronizing between threads and blocking one thread while another thread is calling a method you want protected from simultaneous execution.
3. Look at AutoResetEvent and ManualResetEvent for signalling between threads.
Hope that helps!
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
10x for information but what I mean was - for example:
--------------------------------------------------------
using .... ; //doesn't matter
namespace DllClass
{
public class ClassA
{
private string m_message;
public ClassA()
{
//Empty constr (??)
}
public void ThreadEntrancePoint()
{
//This method will be called when creating
//a new thread
//TODO: Should I put here infinity loop ???
}
//This method will chande variable in this class
public string SetMessage
{
set
{ if (value != null) m_message = value; }
}
}
} // End of DLL file
---------------------------------------------------------
using ....; //All the other
using System.Threading;
using DllClass; //need to create class
namespace MyFormNameSpace
{
public class MyForm: Windows.Form
{
public int Main (...)
{
//Doesn't matter for now
}
//This function will be called when user want's
//to create a new thread
public void btn_CreateThread(...)
{
Thread t = new Thread (new ThreadStart DllClass.ClassA.ThreadEntrancePoint);
t.Start();
}
//This function will be called when user want
//to send a new messge to the class that inside
//thread
public void SendNewMessageToThread (string msg)
{
//TODO: What code should I put here to send
//message to ClassA.SetMessage ??
}
}//class close
}//namespace close
---------------------------------------------------------
You see - in this example I want to completly run ClassA in new thread and also pass some variables to this class and may be receive some inforamtion from it. How I can do that ?
"I have not failed.
I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
|
|
|
|
|
Ok, first off, you can't call ThreadStart() the way you described because you need an instance of the class or the method you're calling has to be static.
If it's static, then anything it manipulates has to be static as well, and that means anything outside of the thread can access it as well, as long as it's static. If you made all the data and methods in ClassA static, then you could simply call ClassA.SetMessage from any thread--main application thread included.
If it's not static, then you need an instance of the object to pass along to the delegate. Since you have the instance, you can also call the SetMessage method from the application thread. For example:
ClassA myClassA=new ClassA();
ThreadStart threadDelegate=new ThreadStart(myClassA.ThreadEntrancePoint);
Thread newThread=new Thread(threadDelegate);
newThread.Start();
myClassA.SetMessage="foobar";
...
I hope that helps. Note that you probably would want a "lock" statement to bracket the setter.
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Hello,
I a one of those bi-lingual programmers who use both VB.NET og C#. While both languages have their strengths and weaknesses I find that one of the thing I am missing the most in C# is background compile which VB.NET does.
Being very interested in the next version of the framework I figured that I could easily find out whether this feature would be included in this version. However, the answer eludes me.
Can anyone tell me if I should expect to see that particular feature in C# in the future release?
Thanks in advance.
|
|
|
|
|
Hello All,
I have an issue that is driving me crazy, no, not that kind of issue.
I have published an interface that I had intended to use to build objects for both client and server. The problem is, I cannot get my projects to recognize that I have declared an event, even though I can see it right there in the code.
A couple of scenarios:
1. If I don't declare an event, then I can use the published interface without any problems.
2. I can write the interface code directly in my project and again, no problem.
The problem with scenario one is that I need to declare events in my interface in order to be able to use them in both the client and the server.
The problem with scenario two is that now I am not publishing an interface, but rather declaring them in the code for both the client and the server objects. Crazy stuff eh
This is my published interface which is compiled into a separate assembly:
using System;
using System.Data;
namespace RemoteObjectInterface {
public delegate void TaskCompleted();
public interface IRemoteObject {
event TaskCompleted TaskComplete; // event to be raised or captured
void StartTask();
string GetHostLocation();
DataTable GetProducts();
}
}
In a separate project, I make a reference to this assembly,
and then create a class that implements it:
using System;
using System.Data;
using System.Timers;
using System.Data.SqlClient;
using RemoteObjectInterface; // Reference to compiled assembly
namespace RemoteObject {
public delegate void TaskCompleted(object sender, TaskCompleteEventArgs e);
public class ProductsDB : MarshalByRefObject, IRemoteObject { // declared implementing interface
private static string _connectDef = "Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;";
public event TaskCompleted TaskComplete;
private Timer tmr = new Timer();
public void StartTask() {
tmr.Interval = 10000;
tmr.Elapsed += new ElapsedEventHandler(tmrCallback);
tmr.Start();
}
private void tmrCallback(object sender, ElapsedEventArgs e) {
tmr.Enabled=false;
if (TaskComplete != null) {
TaskComplete(this,new TaskCompleteEventArgs("Task completed on server"));
}
}
// Get the data from the Products table in the Northwind database and return them to the client.
public DataTable GetProducts() {
string SQL = "SELECT * FROM Products";
// Create ADO.NET objects.
SqlConnection cnProducts = new SqlConnection(_connectDef);
SqlCommand cmdProducts = new SqlCommand(SQL,cnProducts);
SqlDataAdapter daProducts = new SqlDataAdapter(cmdProducts);
DataSet dsProducts = new DataSet();
// Execute the command and retrieve the data.
try {
cnProducts.Open();
daProducts.Fill(dsProducts,"Products");
}
catch(Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
cnProducts.Close();
}
return dsProducts.Tables[0];
}
public override object InitializeLifetimeService() {
return null;
}
// This method allows you to verify that the object is running remotely.
public string GetHostLocation() {
return AppDomain.CurrentDomain.FriendlyName;
}
}
[Serializable]
public class TaskCompleteEventArgs : EventArgs {
private string _result;
public string Result {
get{return _result;}
}
public TaskCompleteEventArgs(string result) {
this._result = result;
}
}
}
If you attempt to compile this code, you receive this error:
'RemoteObject.ProductsDB' does not implement interface member 'RemoteObjectInterface.IRemoteObject.TaskComplete'. 'RemoteObject.ProductsDB.TaskComplete' is either static, not public, or has the wrong return type.
and yet this code with the interface included in the same assembly compiles perfectly fine.
using System;
using System.Data;
using System.Timers;
using System.Data.SqlClient;
namespace RemoteObject {
public delegate void TaskCompleted(object sender, TaskCompleteEventArgs e);
public interface IRemoteObject {
event TaskCompleted TaskComplete;
void StartTask();
string GetHostLocation();
DataTable GetProducts();
}
public class ProductsDB : MarshalByRefObject, IRemoteObject {
private static string _connectDef = "Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;";
public event TaskCompleted TaskComplete;
private Timer tmr = new Timer();
public void StartTask() {
tmr.Interval = 10000;
tmr.Elapsed += new ElapsedEventHandler(tmrCallback);
tmr.Start();
}
private void tmrCallback(object sender, ElapsedEventArgs e) {
tmr.Enabled=false;
if (TaskComplete != null) {
TaskComplete(this,new TaskCompleteEventArgs("Task completed on server"));
}
}
// Get the data from the Products table and return them to the client.
public DataTable GetProducts() {
string SQL = "SELECT * FROM Products";
// Create ADO.NET objects.
SqlConnection cnProducts = new SqlConnection(_connectDef);
SqlCommand cmdProducts = new SqlCommand(SQL,cnProducts);
SqlDataAdapter daProducts = new SqlDataAdapter(cmdProducts);
DataSet dsProducts = new DataSet();
// Execute the command and retrieve the data.
try {
cnProducts.Open();
daProducts.Fill(dsProducts,"Products");
}
catch(Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
cnProducts.Close();
}
return dsProducts.Tables[0];
}
public override object InitializeLifetimeService() {
return null;
}
// This method allows you to verify that the object is running remotely.
public string GetHostLocation() {
return AppDomain.CurrentDomain.FriendlyName;
}
}
[Serializable]
public class TaskCompleteEventArgs : EventArgs {
private string _result;
public string Result {
get{return _result;}
}
public TaskCompleteEventArgs(string result)
{
this._result = result;
}
}
}
This code compiles fine.
Am I missing something here?
John A Vonesh
Senior Developer
Tran-Tech Inc.
BAIT, n. A preparation that renders the hook more palatable. The best kind is beauty
|
|
|
|
|
CyberHawke wrote:
This code compiles fine.
Am I missing something here?
Ew. Nothing like reading a lot of unformatted code in a message.
I'm right in the middle of writing a chapter for my book on remoting and have figured out a lot of things. If you want, email me the entire project--code, solution file, project files, and I'll take a look at today.
Marc
webmaster@knowledgeautomation.com
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Hi All!!!
I have to design an application like access report designer. Where we would have drag n drop contorls like Text Boxes, Check Boxes, Radio Buttons, Labels etc and then have to preview them,select them, resize them and so on.
I was thinkin about Creating standard Contorls but then I realized that its difficult to handle them, for example if you click a textbox to select it for resizing, it will start funtioning, similary if u select checkbox to resize, it will eb checked. And their preview wasnt posisble a well.
So i created my own custom controls using GDI+ whose preview is also possible in PrintPreviewDialog.
Any help (even if is very basic and just provide an idea to take start) will be highly appriciated.
Thanx in Advance
sorry for my bad English.
|
|
|
|