|
It appears you have an assembly version mismatch.
Resolution:
Create a seperate assembly u can both reference from the service and the client (i tend to like give that a fixed version number, not the auto one).
Another problem u could have, that I have seen, is closing a MemoryStream after putting an image thru, causes problems, not sure if this a bug or not, as calling Dispose via an implicit interface call infact works.
top secret xacc-ide 0.0.1
|
|
|
|
|
hello,
"Create a seperate assembly u can both reference from the service and the client (i tend to like give that a fixed version number, not the auto one)."
Could you give me a reference (article, tutorial, book...) to learn how to do it?
Thank you.
|
|
|
|
|
This is basic. Create another assembly that defines the type. Both the client and server project depend on this assembly and use the type defined in that shared assembly.
As far as fixing the version number, go to your AssemblyInfo.cs file and change the AssemblyVersionAttibute value to something fixed (no asterisk - *). If you use an asterisk, the assembly version is automatically generated based on the documentation for the AssemblyVersionAttribute in the .NET Framework SDK. This is a terrible feature that wasn't meant to be in the .NET Framework originally, or so I hear.
.NET assemblies link against versions of other assemblies. Changing the version breaks this linkage, but there are ways to redirect assembly versions. Read Redirecting Assembly Versions[^] in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hello,
I think I have found what is the problem... but I do not know the solution.
The problem is that I am using CAPICOM.SignedData. The process is as follows:
1.- Serialize the struct.
2.- Convert the byte array into a string via System.Text.Encoding.UTF8.GetString() method.
3.- sign the data (the string) with SignedData.sign() method and return the result (a string with a PKCS#7 structure) to the client.
4.- The client verifies the signed data and extracts the SignedData content (a string) which is the serialized struct.
5.- Finally, the client tries to deserialize the struct and it throws the exception.
I think the problem is the SignedData operations because without them I can serialize and deserialize the structs without any problem.
Any suggestions?
thank you.
|
|
|
|
|
hello,
i have solved partially my problem:
-- The problem with the signedData was the conversion from byte array to string: i was converting the byte array (the serialized object) into a UTF8 string instead an Unicode string. So, the solution was to use "System.Text.Encoding.Unicode.GetString()"
-- but now, I have another problem. When the client tries to deserialize the struct it gets the following message exception:
System.IO.FileNotFoundException: File or assembly name WEBSERVICE, or one of its dependencies, was not found.
I have develop a testing Console Application that serializes an object, signs it and verifies it with SignedData, and finally, deserializes it and it works well. So, I think it is a WebServices problem.
It sounds like client can not find the serialized object class or the namespace where it is contained but this is rare for me because the client can instanciate that class.
thank you one more time
|
|
|
|
|
Hi,
I am using C#, in my application main class contained object of another class but I need to call main class function in the contained class but I am unable to call main class(container class) function in contained class and I am unable to set reference of container class in contained class because it Viusal studio gives error "Circular Dependency".
Suggust me solution I can access container class function from contained class.
Thanks.
|
|
|
|
|
|
Hi,
If I put both in same assembly and I think they are in same assembly then how can I get assembly information runtime or how I can get function pointer or call function on runtime by using assembly information. Actually I tried but it creates new instance of contained class but I want a get the same instance and I am unable to find information. I will appreciate if you give me some examples.
Thanks,
-Samir.
|
|
|
|
|
You could also use an assembly that defines an interface (or abstract class, but this seems more appropriate for an interface) that the container class implements. This interface could also be defined in the current dependent assembly (since it already depends on it). This allows you to make late-binding calls. Just pass that interface as your parameter into your contained class (or a property value), which would actually be an instance of the implementation of the interface. This way you won't need to make a circular dependency and it makes your code a little more robust.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
Is there any function that will allow me to copy the security attributes
of a file???
On the MSDN site under documentation of COPYFILEEX they say that "To copy
security attributes, use the SHFileOperation function";
I tried that but it still does'nt copy the security attributes.In Robocopy there is a option /SEC which copies NTFS permissions .....I Wonder how they
have done that.. Can anyone please help me in this.
|
|
|
|
|
You can always use xcopy.exe with the /O option.
The FOF_NOCOPYSECURITYATTRIBS (0x0800) - or rather the lack there of - should work, but will only work on NTFS. Be sure you've declared everything correctly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The is no ".NET" function to do it ... yet. The .NET Framework versions 1.0 and 1.1 don't directly support NTFS permissions. That will change in the .NET Framework 2.0.
Are you talking about copying the File WITH the Security attributes or are you talking about Setting the security attributes (NTFS Permissions) of the File?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I tried to load via reflection System.Windows.Forms.Form but I got an exception SecurityException: StrongNameIndentityPermission .....
Could you help me ??
Thank you.
Wizard_01
|
|
|
|
|
It's called Code Access Security, and you should read about it to understand. Depending on what evidence is presented with your assembly, you may not be able to reflect anything. I recommend you read Understanding .NET Code Access Security[^] here on CodeProject and follow the links to the online .NET Framework SDK for additional information.
The specific permission being requested is for a strongly named assembly, which means you use sn.exe -k KeyFile.snk to generate key pair and enter the absolute or project-relative path in the [assembly: AssemblyKeyFileAttribute] typically found in AssemblyInfo.cs, or add it to a container with sn.exe -i KeyFile.snk MyKeyPair and put "MyKeyPair" (for example) in the [assembly: AssemblyKeyNameAttribute] , also found in the same file (makes it easier to use a single key pair for all your assemblies, which is the common way of signing assemblies for an organization or product).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
So, the problem is that my assembly doesnt have strong name but System.Windows.Forms.dll has ? So ... if I create and sign strong name for my assembly, it will work fine. Am I right ?
Thank you
Wizard_01
|
|
|
|
|
It should. There could be another permission that's demanded after StrongNameIdentityPermission , but only trying it or examining the IL will tell you that.
Assemblies should always be strongly named, anyway. It's really so easy that there's no reason not to do it. It also helps keep your code secure since the assembly is signed with your private key (so keep it private!).
Look at it this way: if you use a type from another assembly without signing, you're essentially linking against the type MyNamespace.MyClass, MyAssembly, Version=1.0.0.0, Culture=neutral ; anyone could replace that and do something malicious. If you sign your assembly (give it a strong name), your type is now MyNamespace.MyClass, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0123456789abcdef . Since only you have that signing key, only you can produce that public key token. This isn't 100% secure (someone could disassemble and change the calling assembly), but nothing always is (native code is better, but not infalable).
As I mentioned earlier, too, it's a good idea to use the same key pair for all your assemblies, or at least for a given solution. It can't be traced back to you like it could if you additionally signed with an X.509 certificate (authenticode; like ActiveX uses), but it is an identifying mark in the way that only you (or your organization - or maybe just the build master) have the private key.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know how to set the cursor while in a 'form' but I want to change the system cursor just before I launch a thread and then change it back to the Arrow when the threaded process completes.
How do I change the system cursor in C#?
cb
|
|
|
|
|
The cursor should not be set for the entire desktop by an application. It's recommended that you set Cursor.Current , which applies to the entire application (Control.Cursor applies only to that window (a control is a window)). There is no reason to set the cursor for the entire desktop, neither. This violates the standard of per-application cursors.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Changing the "system" cursor is unnecessary for a standard application. You should only be concerned about setting UI cues in your application and only your application unless you have very special reasons. Cursor.Current should be more than enough control of the cursor over your application. Set it whatever you want as part of the thread starting set it back to whatever it was before when it is done.
|
|
|
|
|
Thanks, it works like a charm.
cb
|
|
|
|
|
I have a background thead in an Audio program I wrote that scrolls text like a banner. When the text is scrolling I cannot see any TootTips in any other programs. If I stop the Background thread the ToolTips show up again.
Here is the pertinant code:
private delegate void ScrollThreadDelegate();
...
...
ScrollThread = new Thread(new ThreadStart(ScrollThreadFunction));
ScrollThread.IsBackground=true;
ScrollThread.Start();
ScrollThread.Suspend();
...
...
private void ScrollThreadFunction()
{
while(RunScrollThread)
{
if(lbSongInfo.InvokeRequired)
{
this.lbSongInfo.Invoke(new ScrollThreadDelegate(this.ShowScrollText));
}
Thread.Sleep(50);
}
}
private void ShowScrollText()
{
if(lbSongInfo.Location==SongInfoEnd)
lbSongInfo.Location=SongInfoStart;
Point CurPos = new Point(lbSongInfo.Location.X,lbSongInfo.Location.Y);
CurPos.Offset(-1,0);
lbSongInfo.Location=CurPos;
}
private void InitSongInfoLabel()
{
try
{
try
{
ScrollThread.Suspend();
}
catch(Exception){}
string strName = CurTrackItem.SubItems[1].Text;
int strWidth = (int)grfx.MeasureString(strName, lbSongInfo.Font).Width + 5;
SongInfoStart=SongInfoEnd=new Point(0,0);
SongInfoStart.Offset(pnSongInfo.Width,0);
SongInfoEnd.Offset(strWidth*-1,0);
lbSongInfo.Location=SongInfoStart;
lbSongInfo.Width=strWidth;
lbSongInfo.Height=pnSongInfo.Height;
lbSongInfo.Text=strName;
lbSongInfo.TextAlign = ContentAlignment.MiddleCenter;
}
catch(Exception Err)
{
MessageBox.Show("InitSongInfoLabel Exception : "+Err.Message);
}
finally
{
ScrollThread.Resume();
}
}
Can anyone see what might cause this issue?
|
|
|
|
|
Guinness4Strength wrote:
int strWidth = (int)grfx.MeasureString(strName, lbSongInfo.Font).Width + 5;
Where do u get that Graphics instance from? Looks like the cultprit. Also you should be invoking rather directly calling methods on a control from another thread.
top secret xacc-ide 0.0.1
|
|
|
|
|
1. I call CreateGraphics() in the FormLoad event handler.
2. I am using Delegates and Invokes. Take a look at the ScrollThreadFunction()
|
|
|
|
|
Guinness4Strength wrote:
1. I call CreateGraphics() in the FormLoad event handler.
Thats no good, you can only use the Graphics object supplied by OnPaint (and friends).
Guinness4Strength wrote:
2. I am using Delegates and Invokes. Take a look at the ScrollThreadFunction()
A delegate is just a function pointer the way you use it in your example. You need to do Control.Invoke and use the ISyncronizedInvoke interface implementation.
top secret xacc-ide 0.0.1
|
|
|
|
|
1. If using CreateGraphics() is not allowed, why is it there ?
the MSDN exmaple shows it's use inside a function that does not receive any PaintEventArgs:
private void AutoSizeControl(Control control, int textPadding)
{
Graphics g = control.CreateGraphics();
Size preferredSize = g.MeasureString(
control.Text, control.Font).ToSize();
control.ClientSize = new Size(
preferredSize.Width + (textPadding * 2),
preferredSize.Height+(textPadding * 2) );
g.Dispose();
}
2: I AM calling Control.Invoke() and implementing ISyncronizedInvoke interface
<pre?
if(lbsonginfo.invokerequired)
{
this.lbsonginfo.invoke(new="" scrollthreaddelegate="" his.showscrolltext));
}
<="" pre="">
|
|
|
|