|
Does this one ring a bell with anyone? I've got a .cs file I'm trying to compile and it's throwing this error.
error CS5001: Program 'C:\mydll.dll' does not have an entry point defined.
Real programmers don't document. If it was hard to write, it should be hard to understand.
|
|
|
|
|
There's no Main() in your program. Either add one, or use /target:library to create a dll
|
|
|
|
|
Hey what's up coders...
Okay I am going through a Hashtable using an enumerator does the size of the key in bytes actually hinder the time it takes to move through them?
Ie. if I use a short as the key m_htTable[short key] or I use a GUID would the key size really matter. I thought it was all done using address based access, meaning when travesing the hashtable a 32bit address is always used not the actual size of the key.
If anyone knows anything about this could they try and give me and idea on what is actually going on.
Thanks...
|
|
|
|
|
The size of the key doesn't matter.
Hashtable stores all of its keys as object references, so they're all the same size. Note that if you're using value types - such as short - they're boxed, and that can have performance implications if you do lots of accesses.
|
|
|
|
|
I am really frustrated here. I'm sure there is a simple answer but I can't see it.
I used VB.NET some time ago to write a web site, this time I thought I'd use C#.
If I want to access an event handler other than the default for a control in VB, I just use the two drop-down lists at the top of the code view. Select the control in the left-hand box, the event in the right hand. The IDE then does all the work for me (besides, the entire workload consists of having a method that "Handles" the event).
In C#, this isn't possible. The only item in the left-hand drop list is the page and the right-hand list only includes methods already coded.
I thought the answer would be to write the code by hand, for example
<br />
private void dgConfirm_EditCommand(object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e)<br />
{<br />
dgConfirm.EditItemIndex = e.Item.ItemIndex;<br />
dgConfirm.DataBind();<br />
}<br />
But then somewhere I also need to add
<br />
dgConfirm.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(dgConfirm_EditCommand);<br />
This is easy enough in a Windows Form, where I've met the same problem, because I can add it to the constructor. But there is no constructor for a Web Form and the obvious methods (OnInit and InitializeComponent) are entirely within the "Windows Form Designer generated code" region.
I've learned the hard way that editing this is a bad idea.
So that's it, I'm officially out of ideas. Someone must know how to do this... please!!
Paul
|
|
|
|
|
In VS.NET click on the item you wish to add the event for.
Now open up the Properties panel and click the yellow lightning bolt symbol.
Now you should see all the events available, either double-click on the particular event to add a new (empty) event handler or click on the drop-down and choose the event handler you have already created.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Arrgh!
Thankyou James, I've been beating myself up about this most of the afternoon. Don't know why I didn't think of that. *sigh*
Paul
|
|
|
|
|
I am having a problem with serialization and deserialization of classes using the BinaryFormatter. I have two different programs and I want to serialize a class in the Test1 program and transfer it using sockets to the Test2 program and deserialize it into a replica class.
When I attempt to deserialize in the Test2 program, I get the following System.IO.FileNotFoundException:
File or assembly name Test1, or one of its dependencies, was not found.
Here is an example of how I am serializing:
SomeClass sc = new SomeClass();
sc.var1 = 12;
sc.var2 = m_strTemp;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms,(object)sc);
After receiving buffer of serialized data, here is an example of how I am deserializing:
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream(buffer,0,nBytesRead,true,true);
SomeClass sc = (SomeClass)bf.Deserialize(ms);
What am I doing wrong? How can I deserialize in an entirely different process, in a different program, on a different machine and not receive this error?
Thanks!
Donald
|
|
|
|
|
Classes in .NET are assembly specific, so if you and I both create a class called Foo with the exact same code but you have yours in the assembly donald.dll but mine is in the assembly james.dll they are considered incompatible types if the contents of the two assemblies differ.
The way to get around it is to place the classes that will be shared between the two applications into a separate assembly (class library to use VS.NET terms).
Then the client program and the server program both reference this assembly.
HTH,
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
That works very well... thank you very much!
|
|
|
|
|
Hi,
I did a class: "Cls" that has a function: "Pic" that return some Bitmap.
I did a console application that listening on port 9988 and do the Cls class to Single call remote class.
I create the client as a windows apllication, and add a PictureBox- "ThePic" to the form.
In some event(like button click) I get Cls class from the remote server and call to Pic function that return the Bitmap (I call it obj)
Here is the problem:
If I call to metod: obj.save("c:\\a.bmp") the picture is succesfully save to the hard disk. (obj is the remote object).
But if I write: ThePic.Image= obj I get RemotingException, that say:
"Remoting cannot find field nativeImage on type System.Drawing.Image".
But how is can to be? The object is succesfully get to the client, becuase I can save this bitmap to the disk. but if I pass it to PictureBox I get this Exception.
Please, Do you have some idea for me?
Thank's alot,
Itay
|
|
|
|
|
I need a text compression algorithm (preferable open-source etc.) to compress and decompress a few XML files for my project. Anyone has any sources?
It doesn't have to be in C# but if possible it should be easily ported. I will probably port it (and not use the binary).
|
|
|
|
|
How big are the XML Files?
Is it worth it?
Why do you want to compress?
- for reduced storage? or
- increased transmission speed? or
- encryption?
If you can answer the above questions with some really good reasons, then you can use some sort of "Huffman compression algorithm".
You can create a functions like:
- string compress(string fatstring)
- string decompress(string thinstring)
If you get this working, can you email me a copy.
Thanks. Keep up the good work.
Regards
Wooble
|
|
|
|
|
You'll easily find projects like xmill (AT&T but free) and xmlppm (sourceforge).
Remember that XML compression should be at the transport level, not at the application level. In other words, that's not a problem that on the network stack XML is made binary. But that really hurts if for any app or for the end user XML is not human-readable.
That said, Xml compression is well achieved :
- because, by design, element names and attributes appear many times
- because LOV (List Of Values) may appear many times too (for the exact same reasons than with a SQL join)/
And I swallow a small raisin.
|
|
|
|
|
|
If you right click on a JPEG file and select Properties and select the Summary tab there are descriptions of this file such as Date Taken, Author, Summary. How can I get or set this information for a specific file?
Any help would be good.
Thanks
Brandon
|
|
|
|
|
|
I have tried that. It has basic information like file creation date but does not allow to access other file information.
Thanks
|
|
|
|
|
I believe that information is stored somewhere in the JPEG file and that Windows Explorer is reading that information to populate the fields.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
I am writing a simple remoting server and have a little problem.
everytime I restart the server after it has been used by a client I get the following error.
Only one usage of each socket address (protocol/network address/port) is normally permitted
If I leave the machine for about 5 minutes then the problem goes away.
The server code I am using looks like this...
<br />
TcpServerChannel channel = null ;<br />
try<br />
{<br />
channel = new TcpServerChannel (8088) ;<br />
ChannelServices.RegisterChannel (channel) ;<br />
RemotingConfiguration.RegisterWellKnownServiceType (<br />
typeof (ClassLibrary.Class1), "Hi", WellKnownObjectMode.SingleCall) ;<br />
<br />
System.Console.WriteLine ("Hit <enter> to exit") ;<br />
System.Console.ReadLine () ;<br />
}<br />
catch (System.Exception err)<br />
{<br />
System.Windows.Forms.MessageBox.Show (err.Message) ;<br />
}<br />
finally<br />
{<br />
if (channel != null)<br />
{<br />
ChannelServices.UnregisterChannel (channel) ;<br />
}<br />
}
As far as I can tell the unregister Channel always gets called.
How do I ensure that the channel is released so it can be reused?
Thanks
Stephen
|
|
|
|
|
The channel should get automatically unregistered when you quit the application. Since any port that your process is listening on will be closed when your process terminates.
You say that the problem only occurs after a client has used it, does the problem occur if a client dosen't use it and you restart the server?. If that is the case then the probably lies with the client somehow. Maybe you can post the relevant client code as well.
I had a similar problem once but it was on the Client side, the problem there was that i was showing a messagebox and forgot to close it thus the application never completely terminated and the port remained open.
May the Source be with you
Sonork ID 100.9997 sijinjoseph
|
|
|
|
|
Thanks for the reply, If I just start and stop the server I have no problems, the server will restart without the error. Its only if a client has connected that the server has a problem.
Both the Client and server are simple c# console apps.
The client code I am using for this test looks like this..
ChannelServices.RegisterChannel (new TcpClientChannel ()) ;<br />
ClassLibrary.Class1 = (ClassLibrary.Class1 )Activator.GetObject (<br />
typeof (ClassLibrary.Class1), "tcp://localhost:8088/Hi") ;<br />
<br />
for (int i = 0 ; i < 5 ; i++)<br />
{<br />
Console.WriteLine (hello.Greeting ("Stephen")) ;<br />
}
and the remoted object looks like this
public class Class1: System.MarshalByRefObject<br />
{ <br />
public string Greeting (string name)<br />
{<br />
return "Completed" ;<br />
}<br />
}
Both the client and the server fully terminate (i.e. debuger returns and nothing in process list) before I attempt to restart the server.
Thanks
Stephen.
|
|
|
|
|
Not having any luck with this problem, so I downloaded TCPView from sysinternals.com.
Now I can see the server program start and open two ports.
The first is different every time and counts up from about 4010 (the lowest I have seen yet) and the port I am intreased in 8088. The clients connect and all is well. I then close the server and I see ports close in TCPView.
I restart the server and I see the ports reopened and attached to the new server process. Then I get the message
Only one usage of each socket address (protocol/network address/port) is normally permitted
WTF, the ports _where_ opened ok?
It fails on this line of code
channel = new TcpServerChannel (8088) ;
This is the stack trace
at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.StartListening(Object data)
at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.SetupChannel()
at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel..ctor(Int32 port)
at Server.Server.Main(String[] args) in d:\devwork.net\experimentation\remoting\server\server.cs:line 22
If I sit and watch TCPView for five minutes I do not see any ports closing in that period, but the project works again, only the once, after that delay
So I am at a loss now, Don't really know where to go from here, anyone, any ideas?
Anyone know of any good books or articles on remoting?
Thanks
Stephen
|
|
|
|
|
First of all can you also post the server remoting code. Your code seems perfectly allright. Maybe you can use Tracking Services to see what is really going on on the server side. That should be more helpful than using TCPView.
Have you checked Task Manager after closing your server to make sure that it's not running. Your problem is very strange indeed.
May the Source be with you
Sonork ID 100.9997 sijinjoseph
|
|
|
|
|
I think I have found the cause of the problem.
I have the Winsock Proxy Client installed on this machine that lets me connect to the Internet via an ISA server. If I disable the client the problem goes away. This only seemes to affect servers written in dotnet.
I think I will have a look at the tracking services to see if I can find out more detail on why it is going wrong.
Stephen.
|
|
|
|