Reputation: 1
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] Arguments: 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.
Upvotes: 0
Views: 790
Reputation: 182
Here is solution, but it works only for IE
Microsoft.LightSwitch.Threading.Dispatchers.Main.BeginInvoke(() => HtmlPage.Window.Eval("window.clipboardData.setData('Text','testtestest')"));
Upvotes: 0
Reputation: 5065
Are you sure you haven't clicked 'Remember my answer' on your own machine? One way to figure it out on your own machine is to clear your browser cache. I don't think clientaccesspolicy has nothing to do with it. It's the client application that tries to access the client clipboard. The silveright application is running with partial trust in your browser (that's why this confirmation message pops-up on SetText and GetText).
The question to allow clipboard access is also by design. A user should always give permission. You can only write to clipboard access if the action is a user action (like clicking a button).
To avoid the message, you could try running it out of browser with elevated permissions so the user won't get prompted but he will be prompted before to run the application with elevated permissions ;)
So I think you're stuck with a confirmation dialog for the user anyways. It's not a very big deal, once they do remember their selection, they won't be prompted anymore.
Upvotes: 1