Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working with Silverlight 4.0 and I have used Clipboard(System.Windows) class for copying error from the site.

It is working fine in my machine but when I am trying to access it from Others machine, I am getting follwing Error :

"
[Clipboard_AccessNotAllowed]<br />
Arguments:<br />
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.60310.0&File=System.Windows.dll&Key=Clipboard_AccessNotAllowed"


My code is as below :

private void SetMessageToClipboard(string sMessage)
        {
            try
            {
                Clipboard.SetText(sMessage);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }


This error will be disappeared once you select 'Remember my answer' in popup of Silverlight.

Is it related to ClientPolicy.XML file? I have not added it. But I have not found anything in ClientPolicy.XML which can be helpful for me.


Please suggest.
Posted
Updated 22-Jul-18 4:30am
v3

I doubt you can access the clipboard when your code is not running locally. Copying the clients clipboard is surely a potentially hostile behaviour ?
 
Share this answer
 
Silverlight 4 has support to the Clipboard. You need to do this via a user initialized action.
See here[^].
 
Share this answer
 
Comments
PankilSyn_2011 12-Jul-11 6:01am    
Hi Abhinav,

I have already added this Clipborad but while I am accessing it from other's machine, It is giving mentioned error.
Pete O'Hanlon 12-Jul-11 6:23am    
This is a security feature and not one you can disable. Basically, you have to force the user to choose to let your program access the clipboard, so that they can make an informed choice rather than your code just changing things behind the scenes.
PankilSyn_2011 12-Jul-11 6:38am    
Hi Pete,

Thanks for the comment. While we are trying to access the Clipboard, Silverlight will ask the permission from User.

After User has selected 'No' means 'Don't allow to access Clipbord' in Silverlight popup, I am getting this error.

Regards,Pankil Patel
Pete O'Hanlon 12-Jul-11 8:49am    
That's exactly what I'd expect. The user has denied access to the clipboard, so your application has to respect that - this is enforced by the runtime.
PankilSyn_2011 12-Jul-11 9:05am    
Hi Pete,

Yes. User has denied the access to the clipboard. But normally it gives proper exception like 'Clipboard is not allowed' and in rare case (5%) it gives error which I have mentioned in the question.

I did not find any related topics in microsoft site or even from Google :(.

Regards,
Pankil Patel
Its rather very simple:

Go to Start-> All Programs->Microsoft Silverlight-> Microsoft Silverlight(Click it)
This will open Silverlight for you.

Now go to Permissions Tab. You will See clipboard here with permission as Deny.
Click Allow -> Click OK.

Restart your Application and now your Silverlight application should have access to clipboard.

Enjoy Coding,
Ajay
 
Share this answer
 
Right click on blank area -> silverlight -> permissions -> allow clipboard
 
Share this answer
 
Comments
Graeme_Grant 22-Jul-18 10:40am    
This is a 7-year-old question on a discontinued framework. Please answer questions that are current...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900