Getting Exception error when calling WCF Service - wcf

I have a website (client) consuming the WCF service.
This is what the exception error returns when I run the website with the debugger:
ex {"Could not find a part of the path 'E:\\ORG_FILES\\Logs\\P_Log.txt'."} System.Exception {System.ServiceModel.FaultException<System.ServiceModel.ExceptionDetail>}
Inside the web service I have no double \:
String logPath = #"E:/ORG_FILES/Logs/P_Log.txt";

There can be one of the two cause for this error:
1.Path is not correct.
2.Account through which your application is running don't have rights to create directory at path location, like if you are trying to create directory on shared drive with not enough privileges etc.
You can try changing logPath:
string logPath = #"E:\ORG_FILES\Logs\P_Log.txt";
or
string logPath = "E:\\ORG_FILES\\Logs\\P_Log.txt";

Related

There was an error in compiling the proxy code

I have created a very simple wcf serivce and I am trying to use it in Agilepoint nx, but it is giving me this error:
Exception: AgilePoint.Workflow.DataSources.DynamicProxyException: There was an error in compiling the proxy code.
at AgilePoint.Workflow.DataSources.DataSourceDescriptorWCF.OpenWsdl(String urlStr, String domainName, String userName, String userPassword, Boolean isGenerateMessageContract, DynamicProxyFactory& _factory)
at AgilePoint.Workflow.DataSources.DataSourceDescriptorWCF.GetWCFBindingsAndEndpoints(String URL, Boolean generateMessageContract, String CustomDomainName, String CustomUserName, String CustomUserPassword)
at r.GetWCFBindingsAndEndpoints(String wcfServiceUrl, Boolean generateMsgContract, String credentials)
Compilation Errors:
error CS0009: Metadata file 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll' could not be opened -- 'An attempt was made to load a program with an incorrect format. '
Anyone any idea what could be causing this error?
I have changed the identity in app pool to: Localsystem, but it is not working.
Test your web service with wcftestclient or SoapUI.
Looks like you should enable 32bit apps in app-pool settings (if you are hosting service in IIS).

Error hosting WCF service in windows

I am getting the following error when trying to host my WCF service in windows on the server. I am installing it using InstallUtil.exe.
I hosted the same service on my local system. It worked perfectly fine. But not working when trying on the server.
Installing assembly 'D:\wwwroot\ABCServices\ABC.servicehost.exe'.
Affected parameters are:
assemblypath = D:\wwwroot\CareScoutServices\ABC.servicehost.exe
logfile = D:\wwwroot\ABCServices\ABC.servicehost.InstallLog
logtoconsole =
Unable to create an instance of the ABC.ServiceHost.ProjectInstaller installer type.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
The inner exception System.NullReferenceException was thrown with the following error message: Object reference not set to an instance of an object..
Rolling back assembly 'D:\wwwroot\ABCServices\ABC.servicehost.exe'.
Affected parameters are:
assemblypath = D:\wwwroot\ABCServices\ABC.servicehost.exe
logfile = D:\wwwroot\ABCServices\ABC.servicehost.InstallLog
logtoconsole =
Unable to create an instance of the ABC.ServiceHost.ProjectInstaller installer type.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
The inner exception System.NullReferenceException was thrown with the following error message: Object reference not set to an instance of an object..
Can someone please help resolve this error.
This is basic but try running the InstallUtil as an administrator.

Must use exact identifier for APP object with verb SET

I'm following this article on allowing WCF to read data from MSMQ but am getting an error with this command
appcmd set app "MSMQ/MsmqService" /enabledProtocols:net.msmq
MSMQ is the name of my IIS hosted website and MsmqService is the name of the .svc file.
The error I get is
ERROR ( message:Must use exact identifer for APP object with verb SET. )
Here is what my site looks like in IIS
I ran into this today, so here's the fix for the "Exact Identifier" error:
Change
"MSMQ/MsmqService"
To
"MSMQ/MsmqService/"
appcmd simply expects a path that includes a slash at the end (exact identifier).
#Sachin, All you are trying to perform by running this command is to set net.msmq in the enabled protocols of the virtual directory. In this specific command the MsmqService is the name of the vDir under your web site MSMQ. If you create a vDir with name MsmqService and execute this command the command will succeed (not the svc file name). And svc files should have the .svc extension for IIS to be able to invoke the appropriate handlers when a request arrives.
Alternatively you can do the same thing in IIS UI following these instructions:
inetmgr from run prompt
Go to the web site MSMQ
Navigate to the vDir MsmqService. Right click -> Manage application -> "Advanced settings..."
Notice a setting named "Enabled Protocols". Type in net.msmq there. Hit OK.

Exception Using GDAL in WCF Rest Service

I am developing a WCF REST service (.net 4) that uses the GDAL libraries. It works great on my development machine but throws an exception on the server (Windows Server 2008 R2). The code fails at
OSGeo.GDAL.Gdal.AllRegister();
Here's the exception:
20130214081020 Exception Message: The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception.
20130214081020 Exception Stack Trace: at OSGeo.GDAL.GdalPINVOKE.AllRegister()
at OSGeo.GDAL.Gdal.AllRegister()
at RasterValues.GetDemElevation(String latitude, String longitude)
20130214081020 Inner exception Message: The type initializer for 'SWIGExceptionHelper' threw an exception.
20130214081020 Inner exception stack trace: at OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper..ctor()
at OSGeo.GDAL.GdalPINVOKE..cctor()
I have copied the GDAL files to the server and have added the path to those in the PATH environment variable.
Any thoughts on what I'm missing? Thanks!
It turns out that I needed to add the *_wrap.dll files to the bin folder of my service.

error writing file on remote server in WCF

I'm creating a WCF (C#, VS2010) for my silverlight app, I'm trying to create a file on my remote server (where WCF exists), but I get an unknown error, I just get "Server not found" error in WCF function complete exception message, I use following codes to create a file on my remote server (I use a VDS, so I think I don't have permission problems, I use remote desktop on my server)
using (StreamWriter outfile =
new StreamWriter("mytest.htm"))
{
outfile.Write(body);
}
what is going wrong here? is it possible that I have permission problems? I run my WCF on local system and it creates file successfully, but there is no luck when it is uploaded to remote server
should I use Server.MapPath for giving address of my file?
Please use this:
System.Net.FileWebRequest request = (System.Net.FileWebRequest)System.Net.FileWebRequest.CreateDefault(new Uri("\\\\remotelocation\\MyText.txt"));
request.Method = "POST";
Stream requestStream = request.GetRequestStream();
byte [] fileContents = Encoding.UTF8.GetBytes("test_content");
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();