I'm using Visual Studio 2013 and I am trying to create a webservice using the assembly DNSTools from Nuance SDK. My WebMethod is really simple : I just create an object from a DNSTools' class, then return "Hello World".
using DNSTools;
namespace WebTestFinal
{
public class WebServiceTestFinal : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
DgnDictCustom dgn = new DgnDictCustom();
return "Hello World";
}
However when I reach the line :
DgnDictCustom dgn = new DgnDictCustom();
It throws me this error :
System.IO.FileLoadException: Retrieving the COM class factory for component with CLSID {A0E850E3-91DB-11D1-96DC-0080C72FD13C} failed due to the following error: 8007045a. A dll initialization routine failed. (Exception of HRESULT : 0x8007045A).
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at WebTestFinal.WebServiceTestFinal.HelloWorld()
I did some research and found out that System.IO.FileLoadException was thrown because an assembly cannot be loaded. Despite using Fuslogvw.exe and Process Monitor I can't find which assembly is the root of the problem.
Go to Project Properties and in Build Tab, select X86 for platform target, and if it's already X86 change de to 64
In VS - project properties - in the Build tab - platform target =X86
Related
I'm trying to use the office component to convert a excel file to a pdf file ,but I get the exception as blow
<exception><![CDATA[System.Runtime.InteropServices.COMException (0x8000401A): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 8000401a The server process could not be started because the configured identity is incorrect. Check the username and password. (Exception from HRESULT: 0x8000401A).
at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
]]></exception>
However,when I restart the IIS ,everything is ok.And almost two days later,The Exception appear again.
I have this code on my service:
Application xlsApp = new Application();
xlsApp.Visible = false;
Workbook wb = xlsApp.Workbooks.Open(dictionaryPath);
Sheets sheets = wb.Worksheets;
Worksheet ws = (Worksheet)sheets.get_Item(1);
var numberOfRows = ws.UsedRange.Columns["A"].Rows.Count;
var firstCol = ws.Range[dictionaryColumn + "1:" + dictionaryColumn + numberOfRows];
values = firstCol.Value as Array;
And when I run because I don't have Microsoft Office installed on my server I get this error:
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
And I know that one of the solutions is to install the Microsoft Office but I am not allowed to do that so is there any other way to access the excel and not to install Microsoft Office. I use COM Interop and it is included in the project I also tried installing Open XML SDK 2.5 but for some reasons it didn't work. Can some one help me find a solution
I have an app using COM library. When i run it to test in console app it works good. But when i install it as Windows Service using installutil. In logs i have error
Message: (SaveInvoice) - Zapisywanie faktury - FS/12584/2012/01
Nie znaleziono błedu o kodzie: Creating an instance of the COM component with CLSID {F8605331-7454-4A45-98DB-A69EBB3D2947} from the IClassFactory failed due to the following error: 8000ffff Katastrofalny błąd. (0x8000FFFF (E_UNEXPECTED)).
Stacktrace: SaveDocuments.SaveInputDocuments => SaveMethods.SaveInvoice => LogProvider.ErrorException
Exception:
System.Runtime.InteropServices.COMException (0x8000FFFF): Creating an instance of the COM component with CLSID {F8605331-7454-4A45-98DB-A69EBB3D2947} from the IClassFactory failed due to the following error: 8000ffff Katastrofalny błąd. (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)).
at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Rewizor.Application.Start.get_Gt()
at Rewizor.Application.Start.get_Rewizor()
at Rewizor.Parsers.Invoice.InvoiceParser.InvoiceParserVatDocument(CustEDIInvoice invoice)
at Rewizor.ModelRepository.Invoice.InvoiceRepository.CreateInvoice(CustEDIInvoice invoice)
at DALRewizor.RewizorRepository.CreateInvoice(CustEDIInvoice invoice)
at EDIService.BLL.RepositoryBLL.CreateInvoice(CustEDIInvoice invoice)
at BLL.InboxRepository.SaveMethods.SaveInvoice(EDI_OutputStorage item)
Anyone have idea, how to solve it?
One of the common problems in this scenario are user permissions, because the service runs as a different user than that who runs in console. But judging by the comments on the question, you already checked it.
Another source of errors is the fact that the working directory of the console application is the directory where the EXE is located. With Windows Services, it's not; the working directory is C:\Windows\System32 (or wherever %SYSTEMDIR% is). So, if you have code that relies on the current working directory (such as reading a file in the same directory), it will not work as a service. I'm not sure, but maybe the same problem could happen if you are trying to load a COM library in the same path as the EXE.
So, what I suggest you:
Double check your permissions.
Check any code that relies on relative paths and change it to absolute paths instead.
I'm trying to use System.Data.OracleClient instead of Oracle.DataAccess with Fluent Nhibernate . From what I understand, in order to achieve this I should change my driver from OracleDataClientDriver to OracleClientDriver. I've configured it like below, but I get an error that looks like it is still trying to use OracleDataClientDriver. What am I doing wrong?
FluentConfiguration configuration = Fluently.Configure()
.Database(
OracleDataClientConfiguration.Oracle10
.ConnectionString(x => x.FromConnectionStringWithKey(connString))
.Provider<NHibernate.Connection.DriverConnectionProvider>()
.Driver<NHibernate.Driver.OracleClientDriver>()
)
Here is the error, it is still looking for Oracle.DataAccess which I'm trying to get away from.
[NullReferenceException: Object reference not set to an instance of an object.]
NHibernate.Driver.OracleDataClientDriver..ctor() +134
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +113
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
System.Activator.CreateInstance(Type type) +6
NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type) +58
NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings) +194
[HibernateException: Could not create the driver from NHibernate.Driver.OracleDataClientDriver, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.]
NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings) +334
NHibernate.Connection.ConnectionProvider.Configure(IDictionary`2 settings) +233
NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary`2 settings) +558
NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties) +1328
NHibernate.Cfg.Configuration.BuildSettings() +85
NHibernate.Cfg.Configuration.BuildSessionFactory() +102
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +72
Use OracleClientConfiguration and OracleClientDriver instead of OracleDataClientConfiguration and OracleDataClientDriver
FluentConfiguration configuration = Fluently.Configure()
.Database(
OracleClientConfiguration.Oracle10
.ConnectionString(x => x.FromConnectionStringWithKey(connString))
.Provider<NHibernate.Connection.DriverConnectionProvider>()
.Driver<NHibernate.Driver.OracleClientDriver>()
)
The comments in the question solved my problem. I've posted this answer for the benefit of others, #PapaBurgundy & #Rivarolle deserve full credit for the answer.
I have written a C# program that is to interface with Catia v5.18 via OLE/COM. It is going to be a common case where the machine the program is ran on will have multiple versions of Catia installed on it. Both older and newer and installed in any funky order. The last one installed gets to put its settings in the registry.
I'm trying to setup the registry to use a new handle to connect only to a 5.18 CNEXT server. I found the Catia.Application entry in HKEY_CLASSES_ROOT and the CLSID entry. I made copies of these and provided a new UUID for CLSID and came up with the following registry import file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CATIA.Application.v518]
#="OLE CATIA.Application"
[HKEY_CLASSES_ROOT\CATIA.Application.v518\CLSID]
#="{ba3ca493-05fb-4188-a767-f40c03db2672}"
[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}]
#="OLE CATIA.Application" "AppID"="{ba3ca493-05fb-4188-a767-f40c03db2672}"
[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}\LocalServer32]
#="\"C:\\Program Files\\Dassault Systemes\\B18\\intel_a\\code\\bin\\CNEXT.exe\" -env \"CATIA_PLM_Express.V5R18.B18\" -direnv \"C:\\Documents and Settings\\All Users\\Application Data\\DassaultSystemes\\CATEnv\""
[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}\ProgID]
#="CATIA.Application.v518"
[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}\VersionIndependentProgID]
#="CATIA.Application"
I verified that the import worked, but when I run my application I come accross the following error when I try to connect to it.
System.Runtime.InteropServices.C OMException (0x80080005): Retrieving the COM class factory for component with CLSID {BA3CA493-05FB-4 188-A767-F40C03DB2672} failed due to the following error: 80080005 Server execution failed (Exceptio n from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
I'm able to run this program fine on the normal installs using "CATIA.Application" and "CATIA.Application.1", but here is the code I use to connect to the Application if it matters:
public CatiaApplication() {
Type catia_program_id = Type.GetTypeFromProgID( "CATIA.Application.v518" );
try {
this._instance = (Application)Activator.CreateInstance( catia_program_id );
}
catch( Exception ex ) {
throw new ApplicationException( "Failed to access Catia Application: " + ex.ToString());
}
}
Anybody have any ideas? I haven't tried to reboot the box but so far it looks like the changes take effect immediately.
Shouldn't it be this instead?
[HKEY_CLASSES_ROOT\CATIA.Application.v518]
"CLSID"="{ba3ca493-05fb-4188-a767-f40c03db2672}"
where you wrote it:
[HKEY_CLASSES_ROOT\CATIA.Application.v518\CLSID]
#="{ba3ca493-05fb-4188-a767-f40c03db2672}"