|
mdzieg wrote: was exception on server side)
What was the exception? If the server threw an exception, it seems you might be using remote objects. Is that true?
Also, recurse through the InnerException, as this often has useful information.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Yes, client invoke method from CAO object to serialize it.
I just need to save CAO object on client computer.
The exception is thrown on server side.
Type 'System.Runtime.Remoting.ServerIdentity' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
|
|
|
|
|
heh, even serializing in separate thread on server...
<br />
public byte[] GetStream()<br />
{<br />
TestSerializer td = new TestSerializer(Test.EnquireStream);<br />
IAsyncResult ia = td.BeginInvoke(this, null, null);<br />
return td.EndInvoke(ia);<br />
}<br />
<br />
public static byte[] EnquireStream(Test test)<br />
{<br />
MemoryStream stream = new MemoryStream();<br />
BinaryFormatter serializer = new BinaryFormatter();<br />
serializer.Serialize(stream, test);<br />
return stream.GetBuffer();<br />
}<br />
}<br />
delegate byte[] TestSerializer(Test test);<br />
results the same exception, I thought it may be the same problem as with windows forms controls...
|
|
|
|
|
Problem solved:
BinaryFormatter formatter = new BinaryFormatter(new System.Runtime.Remoting.Messaging.RemotingSurrogateSelector(), new StreamingContext(StreamingContextStates.All));
read this: http://msdn2.microsoft.com/en-us/library/system.runtime.remoting.messaging.remotingsurrogateselector.aspx
-- modified at 15:28 Tuesday 23rd January, 2007
|
|
|
|
|
I'm looking for code to enable sharing (read/writable) on a drive, programmatically. Note that this is different from mapping a network drive, of which I've found several examples.
Is it possible to do this programmatically (assuming of course that the app doing this has the right permissions)?
Thanks!
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hey Marc,
I haven't figured out yet how to share a complete drive, but I did manage to share individual folders. I understand why you want to share an entire drive, especially when it's a local drive. There is no need in sharing each individual folder. If your drives look like mine then there's probably ten million of 'em. I though I just post the file sharing solution anyway, is case you're interested.
This is done through the FileShare enumerator.
The .NET Framework provides the File class equipped with methods to create, save, open, copy, move, delete, or provide detailed information about, files. Based on its functionality, the File class is typically used to assist the other classes with their processing operations. To effectively provide this support, all File's methods are static; which means that you will usually not need to declare a File variable to access them. One of the valuable operations that the File class can perform is to check the existence of the file you want to use. For example, if you are creating a new file, you may want to make sure it doesn't exist already because if you try to create a file that exists already, the compiler may first delete the old file before creating the new one. This could lead to unpredictable result, especially because such a file is not sent to the Recycle Bin. On the other hand, if you are trying to open a file, you should first make sure the file exists, otherwise the compiler will not be able to open a file it cannot find. To check the existence of a file, the File class provides the Exists method. Its syntax is:
public static bool Exists(string path);
If you provide only the name of the file, the compiler would check it in the folder of the application. If you provide the path to the file, the compiler would check its drive, its folder(s) and the file itself. In both cases, if the file exists, the method returns true. If the compiler cannot find the file, the method returns false. It's important to know that if you provided a complete path to the file, any slight mistake would produce a false result.
The values of the FileShare enumerator are:
FileShare.Inheritable : Allows other file handles to inherit from this file
FileShare.None : The file cannot be shared
FileShare.Read : The file can be opened and read from
FileShare.Write : The file can be opened and written to
FileShare.ReadWrite : The file can be opened to write to it or read from it
Perhaps you could play around with the enumerator and get it to work.
Cheers,
|
|
|
|
|
You can do this using interop. You will need to use the following:
SHARE_INFO_502 struct
NetShareAdd from Netapi32.dll
I have code, but I will need to clean it up and isolate it before I can post it.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Hi folks!
I guess it's a newbie question in the area of AD/LDAP, but I was wondering how one could implement a single sign-on mechanism with two collaborating applications.
At the moment, I have an application (A) with its own user administration. User names and (hashed) passwords are stored in a database and the application has its own logon dialog that checks login information against the entries in the database.
Another application (B) can use (A) basically by calling the application with some command line options. One command line option is a user name and (plain) password for (A) to use. In this case, (A) stuffs the user name and password into the logon dialog and handles this information as if it was entered manually.
The disadvantage is that (B) has got to know the user names and passwords from (A) for this to work, so I have to manually keep (A)'s and (B)'s users (and passwords) in sync.
Now I wanted to add an option for (A) to use AD/LDAP for user authentication and I think the basic login dialog with AD users and checking with AD if the password is correct can be programmed easily. What I don't know (and I hope one of you can give me a hint in the right direction) is how (B) can give (A) the information that a user already has authenticated himself in (B) and (A) can use these user credentials without asking the password again. AFAIK there's no way to get the plain password out of AD, so (B) can't give the plain password to (A) like before...
Any ideas?
Thanks in advance,
mav
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
On a data grid is there a way to set the current row number? For example if I know that the black pointer on the left is pointing at current row index 10 and I want the current row to be 11 how do I set it?
DataGridView1.CurrentRow.Index is read only.
|
|
|
|
|
Jawa2006 wrote: On a data grid is there a way to set the current row number?
You really want to work with a CurrencyManager, and the BindingSource class does a great job of working with an underlying data source associated with your DataGridView. The BindingSource has a Position property you can use to set the position, which is reflect in the DataGridView.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
i wanna create a form which shows list of all systems in network
If, u know please help.
Thanks
siddhartha
|
|
|
|
|
I seen an article on this subject here on code project some months ago, search through the aricles section.
|
|
|
|
|
i wanna create a form which shows list of all systems in network
If, u know please help.
Thanks
|
|
|
|
|
When fast user switching is enabled, how can a service find out which user is the active user?
(I realise this is more of an operating system question than a C# one, but there didn't seem to be a suitable operating system message board, and I am developing with C#/.NET 2.0, so I hope it's OK here.)
Dave
|
|
|
|
|
Ok, I have to admit that I am more of a VBer (no flames PLEASE) than a C#er here but I am trying to work through something that just does not seem to make sense and am looking for some help. I am trying to convert a OS project called NClass over form C# to VB, mostly just as an exercise in reading C#, learning the REAL differences between the two as well as to end up with a component that I can use latter on.
I have run across the following lines of C# code that, although I can convert it to VB no problem, makes little sense to me and in fact throws an error.
shapes[i].Draw(g, shapes[i].Location - (Size) area.Location + marginSize);
Does C# allow you to cast a Point type to a Size type?
I THINK I get the idea about what they are trying to do here (draw a shape on an image based upon its location in relation to the location of the shape on the drawing area plus adding a bit for a margin) but it simply makes no sense to me that you would be allowed to do this in this manner.
Can anyone enlighten me?
Seems to me this falls into the category of one of those things that C# lets you get away with but is not all that proper.
|
|
|
|
|
Ray Cassick wrote: Does C# allow you to cast a Point type to a Size type?
Yes.
public static explicit operator Size (
Point p
)
Specifically so you can use points in size operations. Otherwise you would have to do something like "new Size(p.X, p.Y)". Of course, that's what's happening internally, I imagine.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
There is an explicit conversion (op_Explicit) defined for a Point to a Size structure.
public static explicit operator Size (Point p)
You can do this in Visual Basic as well. The syntax is just different.
//C#
Point myPoint = new Point();
Size mySize = (Size)myPoint;
'Visual Basic
Dim myPoint As New Point
Dim mySize As Size = CType(myPoint, Size)
'or
'Dim mySize As Size = Point.op_Explicit(myPoint)
|
|
|
|
|
Thanks for that...
I guess you DO learn something new every day.
|
|
|
|
|
I splitted an image into small pieces (segments) and made some functions on them, then now i want to merge (reconstruct) these pieces into one image agian using c#, does anyone know how can I do this?
Thank you
Mayy Magdy Saad
Junior Solutions Developer
|
|
|
|
|
You can create a new Bitmap (an empty one with known size, or a copy of an existing image),
then create a Graphics object for it with Graphics.FromImage
then perform whatever drawing operations you want to apply,
and maybe end it all with a Bitmap.Save()
Luc Pattyn
|
|
|
|
|
Good anwser .. it almost sounds like a breakfast recipe
|
|
|
|
|
|
Hi all,
We have developed a web application with .net 2.0 in asp.net.
I am trying hard for the last couple of weeks to use sitemap for role based access.
we are authenticating users with our custom code (LDAP and database table based on user type).
I am not able to use the role based access for sitemap.
tried enabled securitytrimming in web.config and enabling rolemanager etc. but when i enabled that nothing was visible in the menu bar.
when i dont keep security trimming in web.config i see all the menu items (roles are not applied).
any one who has worked on this, could you please through some light on this.
this is bit urgent.
|
|
|
|
|
Is there a way to compile C# applications to native win32 executables that don't need the framework to be executed?
Thanks in advace.
Mohamed El Gohary
|
|
|
|
|
Yes, using this tool. But doing so is not recommended at all.
|
|
|
|