I have wpf application that calls wcf service with forms authentication.
I added Service Reference to my solution, and in service configuration checked Generate asynchronous operations.
In code behind I created client to that reference,
than I attached event to fire after async method is completed,
then username and pass is setted:
client.ClientCredentials.UserName.UserName = txtUser.Text;
client.ClientCredentials.UserName.Password = passbox.Password;
client.IsAuthenticatedAsync(txtUser.Text, passbox.Password);
client.Close();
in IsAuthenticatedCompletedEventArgs I get error:
"The communication object, System.ServiceModel.Channels.HttpsChannelFactory+HttpsRequestChannel, cannot be used for communication because it has been Aborted."
Does anyone knows why this happens?
Thanks in advance!
To be honest, I haven't had a chance to test your scenario, but that error is a general error stating something went wrong while communicating with the service (this answer is more of a comment, but it's extensive and can't fit). You could get more info by putting the following lines at the end of the <configuration> section in your web.config and app.config:
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "ServiceTestWCFTrace.svclog" />
</listeners>
</source>
</sources>
After you get the error use svc log viewer to view the log: C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\SvcTraceViewer.exe
There you'll probably find the exact error that caused the Abort on the channel. Hope it helps.
Related
I am able to access this gadget in my local dev environment, but not integration, as you can see below:
Local dev:
Integration:
I double checked the BVN settings from here: https://github.com/Geta/404handler#configuration. They are setup like this in my web.config:
<section name="bvn404Handler" type="BVNetwork.NotFound.Configuration.Bvn404HandlerConfiguration, BVNetwork.EPi404" />
<episerver.shell>
<publicModules rootPath="~/modules/" autoDiscovery="Modules" />
<protectedModules rootPath="~/EPiServer/">
<add name="BVNetwork.404Handler" />
<bvn404Handler handlerMode="On">
<providers>
<add name="Custom Handler" type="CompanyName.Business.CustomPageNotFoundHandler, companyname-cms" />
</providers>
</bvn404Handler>
There is not a securedComponents section, though I did try to add one with allowedRoles="Administrator", allowedRoles="*", and allowedRoles="Everyone" for testing purposes.
Any ideas why the gadget can't be viewed when published?
The issue was that the BVN zip file did not publish to the modules folder for some reason. After adding it back, it worked as expected.
Nuget installations sometimes misses the protectedmodules section
Ensure the BVNetwork.404Handler is in your protectedModules collection in web.config. Nuget sometimes miss that.
<episerver.shell>
<protectedModules rootPath="~/EPiServer/"> <!-- this line may vary -->
<!-- other modules -->
<add name="BVNetwork.404Handler" />
</protectedModules>
</episerver.shell>
We're moving a site to a new server, and running into an issue with a custom HTTP Handler. The old server was IIS 6.1, the new server is IIS 10 (Server 2019).
The handler is meant to handle all requests under a certain directory path (which does not physically exist on disc), and retrieve the requested files from Sql Server, where they are stored as bytes. The handler itself is super simple; while I don't think it is relevant, here is the code for the handler, which is located in the App_Code folder.
Public Class GetCaseUpload
Implements IHttpHandler
Public ReadOnly Property IsReusable As Boolean Implements IHttpHandler.IsReusable
Get
Return True
End Get
End Property
Public Sub ProcessRequest(context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim url = context.Request.Url
Dim guid = url.Segments()(url.Segments.Length - 2).Trim("/".ToCharArray())
Dim dbo = GetDbObj()
Dim data = dbo.ExecuteDR(<s>SELECT * FROM dbo.UPLOADS WHERE GUID = <%= dbo.FixString(guid) %></s>)
If data Is Nothing Then
context.Response.ContentType = "text/plain"
context.Response.Write("The requested upload could not be found." & vbCrLf & "GUID: " & guid)
Else
context.Response.ContentType = data("FILETYPE")
context.Response.BinaryWrite(data("FILEBYTES"))
End If
End Sub
End Class
The pipeline is running in integrated mode. Here is the current Handler mapping in system.webServer:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<add name="GetCaseUploadFile" path="*/cases/uploads/*" verb="GET" type="GetCaseUpload" resourceType="Unspecified" preCondition="integratedMode" />
... others removed for brevity ...
</handlers>
</system.webServer>
I just flat-out deleted the handler entries from the old server, and readded it through the Add Managed Handler dialog in the Handler Mappings section of the site in IIS management console, and that is what it created.
Also, since these files are not ones normally handled by IIS (PDF, JPGs, DOCs, etc.), I've tried adding
<modules runAllManagedModulesForAllRequests="true" />
Although it was working on the old server without needing that.
Any time I try to pull up a file from that directory though, it always returns a 404.0 error, and shows that the request was mapped to the Static File handler. I've turned on Failed Request Tracing, and see the logs for the requests, and nowhere in the details does it ever even mention that it loaded my handler. If I search through the raw XML file, the name of my class is not found at all.
Here is the detailed error screen being shown:
You need to put the handler code in web.config file as suggested in the below section:
<handlers>
<add name="MyHandler" verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</handlers>
If your application pool running in Classic mode, then the handler reference needs to go into the following section:
<system.web>
<httpHandlers>
<add verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</httpHandlers>
</system.web>
If your application pool running in Integrated pipelined mode, then the handler reference needs to go into the following section:
<system.webServer>
<handlers>
<add name="MyHandler" verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</handlers>
<system.webServer>
so first check your application pool mode and set the handler code.
I had the same issue. Service that implements IHttpHandler running fine on IIS 6 migrated to IIS 10 and needed to work out the required config tweak in order to overcome migrated service getting 404.
Answer provided by Jalpa Panchal did the trick.
I have a Windows Service that uses .NET Remoting (yes I know remoting has been replaced by WCF but this is a legacy application).
When I run the service I get this:
Exception Type: System.Runtime.Remoting.RemotingException Message:
Server encountered an internal error. For more information, turn off
customErrors in the server's .config file.
I have this in my application's config file:
<configuration>
<system.runtime.remoting>
<!-- other settings go here -->
<customErrors mode="Off" />
</system.runtime.remoting>
</configuration>
Oddly, I still get this exception. What am I doing wrong?
I have a wpf application which will call a class library as a plugin to connect with wcf service every time. When call a service method in class library, it will give the above exception. And the exception message is
er = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}Even the stack trace also has the above message. What is the solution?
I'm just guessing here, as you don't provide much code. But in your main application make sure to add the following eventhandlers;
DispatcherUnhandledException
AppDomain.CurrentDomain.UnhandledException
TaskScheduler.UnobservedTaskException
As also documented in this thread:
http://stackoverflow.com/questions/1472498/wpf-global-exception-handler
Log your exceptions with something like Log4net. Regarding WCF, all calls should be wrapped in a try catch block.
If your error is WCF related you can take your service's app.config file and add the following configuration:
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true" >
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="myUserTraceSource"
switchValue="Information, ActivityTracing">
<listeners>
<add name="xml"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\temp\wcf.svclog" />
</sharedListeners>
This will log all WCF activity to c:\temp\wcf.svclog which you may view using the tool SvcTraceViewer.exe located in your win sdk directory.
Hope it helps
Stian
It appears I the data binding errors can be logged via Bea Stollnitz blog entry.
How can I send Data Binding errors through log4net instead of TraceSources or at the very least route the TraceSource to log4net?
Implement a trace listener that writes log messages with log4net. An example can be found here:
How to log Trace messages with log4net?
EDIT (Configuration Example):
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="Log4netTraceListener" type="NameSpace.YourClass, YourAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...." />
</listeners>
</trace>
</system.diagnostics>