WCF Service is showing error after implemented in IIS - wcf

In my project I am using Enterprise Library to connect to database. It is working fine when I run the application from Visual Studio directly.
But this is showing error connecting to database when hosted in IIS on same machine. I have added log trace and got the following error
Resolution of the dependency failed, type =
"Microsoft.Practices.EnterpriseLibrary.Data.Database", name =
"(none)". Exception occurred while: while resolving. Exception is:
InvalidOperationException - The type Database cannot be constructed.
You must configure the container to supply this value.
----------------------------------------------- At the time of the
exception, the container was:
Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,(none)
| Exception:Microsoft.Practices.ServiceLocation.ActivationException:
Activation error occured while trying to get instance of type
Database, key "" --->
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the
dependency failed, type =
"Microsoft.Practices.EnterpriseLibrary.Data.Database", name =
"(none)". Exception occurred while: while resolving. Exception is:
InvalidOperationException - The type Database cannot be constructed.
You must configure the container to supply this value.
----------------------------------------------- At the time of the
exception, the container was:
Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,(none)
---> System.InvalidOperationException: The type Database cannot be
constructed. You must configure the container to supply this value.
at
Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.GuardTypeIsNonPrimitive(IBuilderContext
context, SelectedConstructor selectedConstructor) at
Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.PreBuildUp(IBuilderContext
context) at
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext
context) at
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlanCreatorPolicy.CreatePlan(IBuilderContext
context, NamedTypeBuildKey buildKey) at
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext
context) at
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext
context) at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type
t, Object existing, String name, IEnumerable1 resolverOverrides)
--- End of inner exception stack trace --- at
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object
existing, String name, IEnumerable1 resolverOverrides) at
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String
name, IEnumerable`1 resolverOverrides) at
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type
serviceType, String key) --- End of inner exception stack trace ---
at
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type
serviceType, String key) at
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String
key) at
Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.InnerCreateDatabase(String
name)
My web.config of service is contains as below
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>
</configSections>
<dataConfiguration defaultDatabase="OracleConnection">
<providerMappings>
<add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data" name="Oracle.DataAccess.Client"/>
</providerMappings>
</dataConfiguration>
<connectionStrings>
<add name="OracleConnection" providerName="Oracle.DataAccess.Client" connectionString="User Id=***;Password=****;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=*****)(PORT=1500)) (CONNECT_DATA=(SERVER = DEDICATED) (SERVICE_NAME =*****)));"/>
<add name="SybaseConnection" connectionString="providerName=Sybase.ASEOLEDBProvider;Server=****;Port=5050;Catalog=**;User Id=***;Password=****"/>
</connectionStrings>
I tried a lot but unable to find the cause of issue. :(
I checked the permission on the folder and Everyone has full control. WCF Service in IIS Anonymous access is enabled.
Could anyone please help?

The assembly you are using cannot find one of the assemblies it depends on, make sure all dependencies are either in the GAC or in the bin folder of your web app.

When i enabled 32 bit applications in IIS the error has been changed to
ORA-12638: Credential retrieval failed
The connection string is correct which is working with visual studio.
Is there any setting we need to do in Oralce part to acces connection from IIS?
This worked fine when updated sqlnet.ora file of oracle.

Related

factory.CreateConnection() generates a None of the specified endpoints were reachable;

We have a simple RabbitMQ .NET Client in ASP.NET Web App run under IIS 8. We do not use any SSL and the connection code is simple.
var factory = new ConnectionFactory()
{
HostName = hostname,
UserName = username,
Password = password,
VirtualHost = vhost,
Port = 5672
};
var connection = factory.CreateConnection();
The last line generates the following exception
Exception Occurred
Type: RabbitMQ.Client.Exceptions.BrokerUnreachableException
Message: None of the specified endpoints were reachable
Stack Trace: at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 505
at Org.Prod.Dependency.Concrete.Queuing.RabbitMqProdMessenger.SendMessage[TMessage](String hostname, String username, String password, String vhost, String target, TMessage message, Boolean targetIsExchange)
Source: RabbitMQ.Client
Inner Exception
Type: System.IO.IOException
Message: connection.start was never received, likely due to a network timeout
Stack Trace: at RabbitMQ.Client.Framing.Impl.Connection.StartAndTune() in /_/projects/RabbitMQ.Client/client/impl/Connection.cs:line 1074
at RabbitMQ.Client.Framing.Impl.Connection.Open(Boolean insist) in /_/projects/RabbitMQ.Client/client/impl/Connection.cs:line 707
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IFrameHandler fh) in /_/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs:line 646
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 495
Source: RabbitMQ.Client
Interestingly, when the same code is put in a console app and the binaries are shipped to the same server running the App, the console app connects fine and is able to publish messages.
What is wrong with Web Application trying to do the same thing the console app is doing?
It was an assembly binding failure of System.Threading.Tasks.Extensions, our exception logger was not logging the InnerException
Exception information:
Exception type: FileLoadException
Exception message: Could not load file or assembly 'System.Threading.Channels, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection..ctor(ConnectionFactory factory, String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 494
Very poor misleading error message.
In my case I received the exact same exception when calling factory.CreateConnection(); I am using RabbitMQ.Client 6.2.1 in a library that was dependant on System.Buffers 4.5.1 and my main assembly referenced System.Buffers 4.4.0, updated my main assembly to reference version 4.5.1 of System.Buffers, which involved a lot of other dependent Microsoft. and System. assemblies being removed first before I could remove then re-add System.Buffers via NuGet Package Manager as this told me I had 4.5.1 when my .csproj file said it was referencing 4.4.0. Once this reference issue was resolved the problem went away and I could connect to the RabbitMQ server.

Could not load type ImageResizer.InterceptModule

ImageResizer is setup and working in our test and development environments, however we can not get it working in our production environment. I have setup the IIS site the same (except for the name etc) and have the same Web.config options (only ImageResizer related things in there).... and no dice. We keep getting the error below. We have already tried re-downloading the files, and we checked the other suggestions. All to no avail.
.NET Version 4.5.2.
dll version 4.0.4.934 (we also tried with 4.0.5)... same result.
At the very bottom of the error page, the following displays... which may explain things? .NET 4.5.2 is on the server but it looks like the site is not configured to use it, perhaps?:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34274
Server Error in '/' Application.
Could not load type 'ImageResizer.InterceptModule'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Could not load type 'ImageResizer.InterceptModule'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Could not load type 'ImageResizer.InterceptModule'.]
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +12512121
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +76
[ConfigurationErrorsException: Could not load type 'ImageResizer.InterceptModule'.]
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +12425644
System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +69
System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +62
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +299
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1262
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +133
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Could not load type 'ImageResizer.InterceptModule'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12618980
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12458597
web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="resizer" type="ImageResizer.ResizerSection,ImageResizer" requirePermission="false" />
</configSections>
<resizer>
<!-- Unless you (a) use Integrated mode, or (b) map all requests to ASP.NET,
you'll need to add .ashx to your image URLs: image.jpg.ashx?width=200&height=20 -->
<pipeline fakeExtensions=".ashx" defaultCommands="autorotate.default=true" />
<diskcache dir="/cache" />
<plugins>
<add name="DiskCache" />
<!-- <add name="PrettyGifs" /> -->
<!-- <add name="SimpleFilters" /> -->
<!-- <add name="S3Reader" /> -->
</plugins>
</resizer>
<system.web>
<httpModules>
<!-- This is for IIS7/8 Classic Mode and Cassini-->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<!-- This is for IIS7/8 Integrated mode -->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</modules>
</system.webServer>
</configuration>
Additional Error Info...
Could not load file or assembly 'ImageResizer' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'ImageResizer' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'ImageResizer' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Even though our test environment has the "bin" folder setup as a virtual directory in IIS, this did not work in our production environment. It most likely has to do with the way the drives and site roots and content are setup and stored.
Test VM:
IIS Site Root -> X:\some.site\wwww
"bin" virtual directory -> Y:\bin
Prod VM:
Does not work:
IIS Site Root -> X:\some.site\wwww (which is a symlink to a SAN share)
"bin" virtual directory -> C:\bin
Works:
"bin" is a directory in the site root (on the SAN share)
Thanks Nathanael for the help.
For my case, I accidentally changed the directory of the Default Website on IIS to the root folder of one of my projects whose web.config file includes the ImageResizingModule.
I fixed the issue by just changing the physical path of the Default Website on IIS to the wwwroot folder.

Microsoft Service Bus 1.1 configuration wizard fails - The LDAP server is unavailable

I use the service bus configuration wizard and, while everything seems fine during validation, in the end I get this:
[Error] [20/2/2014 11:07:14 ]: System.Management.Automation.CmdletInvocationException: The server could not be contacted. ---> System.DirectoryServices.AccountManagement.PrincipalServerDownException: The server could not be contacted. ---> System.DirectoryServices.Protocols.LdapException: The LDAP server is unavailable.
at System.DirectoryServices.Protocols.LdapConnection.Connect()
at System.DirectoryServices.Protocols.LdapConnection.SendRequestHelper(DirectoryRequest request, Int32& messageID)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request, TimeSpan requestTimeout)
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
--- End of inner exception stack trace ---
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType)
at System.DirectoryServices.AccountManagement.UserPrincipal.get_Current()
at Microsoft.ServiceBus.Commands.ServiceBusBaseCmdlet.CreateAdminGroup(String adminGroup)
at Microsoft.ServiceBus.Commands.NewSBFarmBase.ProcessRecordImplementation()
at Microsoft.ServiceBus.Commands.ServiceBusBaseCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
--- End of inner exception stack trace ---
at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at Microsoft.ServiceBus.ConfigWizard.CommandletHelper.InvokePowershell(Command command, Action`3 updateProgress)
at Microsoft.ServiceBus.ConfigWizard.ProgressPageViewModel.CreateSBFarm(FarmCreationModel model)
Ideas anyone?
EDIT:
I have tried disabling my firewall completely, I enabled and started the "SQL Server Browser" service, tested my credentials, and I am completely clueless...
(I also have the SQL Server instance on my local machine, if that matters)
EDIT2:
After trying with another user account (the one I was inserting in the wizard) I got this:
[Error] [21/2/2014 10:24:39 πμ]: System.Management.Automation.CmdletInvocationException: Starting service Service Bus Gateway on machine TURBOX-PC failed: Time out has expired and the operation has not been completed. ---> Microsoft.ServiceBus.Commands.Common.Exceptions.OperationFailedException: Starting service Service Bus Gateway on machine TURBOX-PC failed: Time out has expired and the operation has not been completed. ---> System.ServiceProcess.TimeoutException: Time out has expired and the operation has not been completed.
at System.ServiceProcess.ServiceController.WaitForStatus(ServiceControllerStatus desiredStatus, TimeSpan timeout)
at Microsoft.ServiceBus.Commands.Common.SCMHelper.StartService(String serviceName, Nullable`1 waitTimeout, String hostName)
--- End of inner exception stack trace ---
at Microsoft.ServiceBus.Commands.Common.SCMHelper.StartService(String serviceName, Nullable`1 waitTimeout, String hostName)
at Microsoft.ServiceBus.Commands.ServiceBusConfigHelper.StartSBServices(String hostName, Nullable`1 waitTimeout)
at Microsoft.ServiceBus.Commands.AddSBHost.ProcessRecordImplementation()
--- End of inner exception stack trace ---
at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at Microsoft.ServiceBus.ConfigWizard.CommandletHelper.InvokePowershell(Command command, Action`3 updateProgress)
at Microsoft.ServiceBus.ConfigWizard.ProgressPageViewModel.AddSBNode(FarmCreationModel model, Boolean isFirstCommand)
EDIT :
Using a different account and different port numbers (the default didn't work) I have managed to configure the SB, but now for some reason it still tries to use the default ports...
Does this thing work on ports other than the default ones?
If you are logged in as a domain user you need contact with the domain controller. This is what is failing for you.
I got this same error when trying to install service bus on my work laptop at home. When back at the office the installation was successful.
Some additional information about system requirements here: https://msdn.microsoft.com/en-us/library/dn441409.aspx

Bind to Moniker not working on Windows XP 32bit using LDAP

I have the following code:
<appSettings>
<add key="rootDN" value="LDAP://[The rest of the path]"/>
</appSettings>
string rootDN = System.Configuration.ConfigurationManager.AppSettings["rootDN"];
object ou = Marshal.BindToMoniker(rootDN);
This is producing an error:
Unhandled Exception:
System.Runtime.InteropServices.COMException
(0x80072020): A n operations error
occurred. (Exception from HRESULT:
0x80072020) at
System.Runtime.InteropServices.Marshal.MkParseDisplayName(IBindCtx
pbc, St ring szUserName, UInt32&
pchEaten, IMoniker& ppmk) at
System.Runtime.InteropServices.Marshal.BindToMoniker(String
monikerName) at
LDAP_CreateGroup.Program.Main(String[]
args)
Works fine on Windows Server 2008, not working on XP. Unfortunately need this to run on XP.
Must be logged on as domain user, run as user didn't work.

Security exception on IIS 7.5 with no shared folder

I get an exception after upgrading Spring.NET 1.2 to 1.3 in my web application. Here's the setup on my web app:
I created an application pool with its identity set to ApplicationPoolIdentity. I use NHibernate 2.1, my SQL Server 2008 is local and I'm using SQL server authentication. There's no network or shared folder. Everything is local.
Now the weird thing is that if I change identity of my application pool in IIS to NetworkService, it starts working fine. I wonder what is the problem with setting the identity of my application pool to ApplicationPoolIdentity.
Here's the exception:
System.Configuration.ConfigurationErrorsException: Error creating context '/project1': That assembly does not allow partially trusted callers. ---> Spring.Objects.Factory.ObjectCreationException: Error thrown by a dependency of object 'MyObj' defined in 'file [D:\Projects\MyProject\Configs\Services.xml] line 37' : Initialization of object failed : Failed to create an instance of 'Spring.Data.NHibernate.Bytecode.ProxyFactoryFactory'!
while resolving 'Sleepers[0]' to 'CustomerManager' defined in 'file [D:\Projects\MyProject\Configs\Business.xml] line 64'
while resolving 'CustomerDAO' to 'CustomerDAO' defined in 'file [D:\Projects\MyProject\Configs\Dao.xml] line 50'
while resolving 'SessionFactory' to 'SessionFactory' defined in 'file [D:\Projects\MyProject\Configs\Dao.xml] line 21' ---> NHibernate.Bytecode.HibernateByteCodeException: Failed to create an instance of 'Spring.Data.NHibernate.Bytecode.ProxyFactoryFactory'! ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type)
at NHibernate.Bytecode.AbstractBytecodeProvider.get_ProxyFactoryFactory()
The action that failed was:
LinkDemand
The assembly or AppDomain that failed was:
NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
The Zone of the assembly that failed was:
Internet
The Url of the assembly that failed was:
file:///D:/Projects/MyProject/bin/NHibernate.DLL
--- End of inner exception stack trace ---
IIS is trying to load and execute the assembly from the address: file:///D:/Projects/MyProject/bin/NHibernate.DLL.
Executing this will solve those permission issues within that machine:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -addgroup 1.2 -url
"file:///D:/Projects/MyProject/bin/*" FullTrust