I have developed a Silverlight application locally on my laptop.
Everything works fine however when I deploy it to the server the web service runs fine, in that it talks to the data base and gets the desired results. My problem lies with the front-end SL app where it is bringing up this error:
Debugging resource strings are unavailable
at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at FrontEnd.WebService.UIDReturnCompletedEventArgs.get_Result()
at FrontEnd.Views.Users.client_UIDReturnCompleted(Object sender, UIDReturnCompletedEventArgs e)
at FrontEnd.WebService.Service1SoapClient.OnUIDReturnCompleted(Object state)
Caused by: [Async_ExceptionOccurred]
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.1.10329.0&File=System.dll&Key=Async_ExceptionOccurred
So I went to the link given and it stated that is was a Async_ExceptionOccurred error.
Is this a timing issue? The UIDReturnis a web method that brings back a user ID from the database, this is initiated on page load of the Silverlight page, I thought perhaps the value was not back in time and therefore this is why it was crashing however this works locally and on the test server so perhaps it is an IIS issue?
Here is where the web service is called-
void OnLoadCompleted(object sender, RoutedEventArgs e)
{
string fullUserName = WebContext.Current.User.DisplayName;
string userName = fullUserName.Substring(fullUserName.IndexOf('\\') + 1);
WebService.Service1SoapClient client = new WebService.Service1SoapClient();
client.UIDReturnCompleted += new EventHandler<UIDReturnCompletedEventArgs>(client_UIDReturnCompleted);
client.UIDReturnAsync(userName);
}
The fullUserName is from the current logged in user, perhaps this value has not been loaded yet and due to this it is breaking the connection.
This seems to be related to this post to which I have previously answered: Consume WCF library in Silverlight 4 application
Related
For a project I am working on I have to interface with a third-party DCOM library. I started with COM interop and this worked just fine locally, then I switched to DCOM and now I keep getting an unauthorized access exception (0x80070005) when trying to bind an event handler to the exposed event. Below is a summary of what I do in code:
public void connect(string server)
{
object dcomObj = null;
var guidB = Guid.Parse("c8c1f57f-0d7c-40b3-b17c-2eac12512006");
var typ = Type.GetTypeFromCLSID(guidB, server, true);
object[] url = { new UrlAttribute(server) };
dcomObj = Activator.CreateInstance(typ, null, url);
user = (RemoteObjectInterface)dcomObj ;
user.getState(); //works fine locally and remotely
user.stateChange += this.User_StateChange; //only works locally
}
I tried setting every permission I could find on the web but I without success. Does anyone have an Idea as to why only the binding of events fails?
RemoteObjectInterface inherits from both the IRemoteObjectEvents and the IRemoteObject. These interface come from the interop ms generated for me when I imported the original dll.
The server is a windows server 2003 VM in virtual box with a bridged network adapter. On the server Everyone is admin (including guest) and limits are set to full access and defaults are set to full access. I am building and running my code on c# .net 4.5.2 from a Windows 10 machine using visual studio 2015.
The sample application that comes with the SDK also fails when I try to use it remotely, the server registers the user but the sample application never realizes that it logged in successfully, I suspect that this behaviour is related to the failing of event binding.
TL;DR I can get and use a remote object but when I try to add an event handler I get an unauthorized exception (0x80070005), why does this happen on event binding? And how do I fix it?
I had the same problem.
For me the issue was I had a AD running on the same device and had to disable the loopback check in the registry. Other solution could be better I assume, but for me the registry hack will do.
i have used the Http.Current.Response in my global.asax.cs Application Start. It is working fine without any issue when i execute in my PC. How ever when i try to put it in IIS with Windows Server 2008 R2, i find that it is giving the following error.
the code for it is
public static void SetCookie(string key, string value, int dayExpires)
{
HttpCookie encodedCookie = HttpSecureCookie.Encode(new HttpCookie(key, value));
encodedCookie.Expires = DateTime.Now.AddDays(dayExpires);
HttpContext.Current.Response.Cookies.Remove(key);
HttpContext.Current.Response.Cookies.Add(encodedCookie);
}
I wanted to trace out why it is getting executed in my system, but not in IIS.
Thanks
I would not do request/response oriented things in Application_Start. Try doing it in BeginRequest.
The request context is not available in application start when running in integrated mode in IIS7.
Please see my question and the accepted answer here for details:
Global ASAX - get the server name
Would also note that there seems to be a logical bug in your code - this will set the cookie only for the person that hits the site when the application starts - this will not run for every request, or every session.
i want to debug my program but i can't host my silverlight project in VS 2010
here is the message that the VS send to me:
"the Silverlight project you are about to debug uses web service. Call to the web service will fail unless the Silverlight is host and launched from the same web project contains the web service"
when I search about it in the web i saw that the problem is that I'm not doing it local
so when I tried to change this line
endpoint address="http://xxx.xx.x.x/WebService/Service1.svc"
to
endpoint address="http://localhost/WebService/Service1.svc"
on this file:
ServiceReferences.ClientConfig
update!!
i tried now to do it like this:
endpoint address="http://localhost:54502/Service1.svc"
and i got and error that says:
the remote server returned an error:NotFound
here:
public int EndAddParticipant(System.IAsyncResult result) {
object[] _args = new object[0];
int _result = ((int)(base.EndInvoke("AddParticipant", _args, result)));
return _result;
what should i do to change it?
i saw that i need to turn on the debug in web.config file but it was already on.
You didn't explain well so here are a bunch of answers:
When you created your solution, you should have told it to host in a web site.
You can do this after the fact but it is a lot of work (for a new guy), you're better off starting over and copying your code from your silverlight project.
If you did but you are trying to connect to another web site as your web service, you will have to implement a Cross Domain configuration file. This opens a big security hole though.
If you have the 2 projects, but your issue is just the "ServiceReferences.ClientConfig" file not pointing the the right server, you need to include the PORT when debugging locally. It should look something like this:
http://localhost:12345/Service1.svc
Where 12345 is the port of your local web service. You can find this out by looking at the "Web" tab of your project properties.
Hope one of these does it. If not, please provide a little more info, like all the important stuff behind the phrase, "it didn't work"!
i have made window application, which checks new announcements on sharepoint 2007 site, if any new announcemnt is found it shows it as link in my win application.
application is running fine on my server machine, but when i try to run my window application from normal machine it gives me:
System.IO.FileNotFoundException: The
Web application at
http://Server-Name:Port-Num/lists/announcements/Allitems.aspx could not be found. Verify that you
have typed the URL correctly. If the
URL should be serving existing
content, the system administrator may
need to add a new request URL mapping
to the intended application.
this machine exists on LAN, as i can access site from my browser, but when it comes to win application it gives me the above error on following line:
string rawurl = "http://192.168.1.105:1625/";
SPSite site = new SPSite(rawurl); // this line gives error
It should throw an exception because the Server Object Model you are using like SPSite, SPWeb will not work unless it's on the server either web application or windows application.
If you want to get data from a remote sharepoint server you should use SharePoint Web Services.
This article will help you http://www.infoq.com/articles/swanson-moss-web-services
References:
http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/570a4734-d11e-4385-bb97-8625013ebe99/
http://objectmix.com/sharepoint/296959-object-model-new-web-site-creation-remote-sharepoint-server.html
make sure the alternate access mapping is correctly set
so if you can call a page with multiple name (machine name and alias like xxxx73 and portauat) note that may only one works in visual studio so try to fix mapping in central admin or call the page with default main url.
for me noting this small tip, fix my problem in my Sharepoint 2010 UAT environment
There is a Windows Service on Windows Server 2003 (Amazon Virtual Machine). Some applications can communicate with it (using pipes, but there is an wrapper to do it). It is tested and it works. Also, there is a Web Service written in C# (ASP.NET) which communicates with mentioned Windows Service. When Web Method is called, it creates an instance of the class and calls a function - the function "connects" to Windows Service and post a job to it. But, if inside Web Method is created a thread and the function which "connects" to Windows Service is called inside a thread - connection fails. Connection to Windows Service uses pipes. Web Service works on IIS7. It is worth to mention that all works on my local machine, either from debugger (local server started by VS 2010) or from IE when I call Web Method on Web Service which works on local IIS7. In local all works - but on Amazon Instance doesn't. I'm not a web programmer, so I think there is some issue with security. Any hint? Thanks.
EDIT: Uwe's comment reminded me - the Web Method at first tries to download some files using http and it saves them to path C:\intetpub\wwwroot\files\". It works if files are downloaded from the web method, but download fails if it is done from another thread created in Web Method. Exception was: Access is denied. So, I changed security settings on mentioned folder and explicitly allowed user created by IIS7 (IIS_IUSRS) to read/write the folder, and now files can be downloaded. It seems that the source of these problems is the same.
EDIT: The solution is moved to an answer on Will's suggestion.
Ok guys, the solution is found and as Will recomends, I'll post it here, as an answer to my own question. So, the solution:
The problem was because the thread created by Web Method has to be impersonated. So, in the caller method I had to something like:
[WebMethod]
public void Fnc()
{
...
...
System.Security.Principal.WindowsIdentity wi = System.Security.Principal.WindowsIdentity.GetCurrent();
System.Threading.Thread postJobThread = new Thread(PostJobThread);
postJobThread.Start(wi);
...
}
...
private void PostJobThread(object ob)
{
System.Security.Principal.WindowsIdentity wi = (System.Security.Principal.WindowsIdentity)ob;
System.Security.Principal.WindowsImpersonationContext ctx = wi.Impersonate();
...
// Do some job which couldn't be done in this thread
...
// OK, job is finished
if(ctx != null)
ctx.Undo();
}
That's all. Thanks to guys who commented my question and I hope it'll be useful for somebody else.