Visual FoxPro OLEDB error: Invalid path or file name - c#

We have Novell server and there Advantage Database Server 9.1 is installed and all other Xbase++ programs access DBF files from that location.
I want to access DBF files from C# asmx webservice.
Problem is if I use Visual FoxPro VFP OLEDB then it only works while running asmx webservice in Visual studio's Debug mode but when I publish it to IIS, it gives this error:
System.Data.OleDb.OleDbException: Invalid path or file name
First Attempt (with ADS OLEDB):
It works ONLY when DBF files are not opened by non-ADS program. If any Xbase++ program first opens DBF file then "Locking situation" occurs and I can't access DBF file.
ADS connection string:
string connectionString = string.Format(#"Provider=Advantage OLE DB Provider;data source={0}; Advantage Server Type=ADS_REMOTE_SERVER;SecurityMode=ADS_IGNORERIGHTS;TableType=ADS_CDX;Locking=ADS_COMPATIBLE_LOCKING;", folderPath);
Second Attempt (with VFP OLEDB):
Then I tried VFP OLEDB but it only works when I run asmx webservice from Visual Studio's Debug mode and does not work after deployment to IIS, when I publish webservice to IIS it gives this error:
System.Data.OleDb.OleDbException: Invalid path or file name.
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
VFP connection string:
string connectionString = string.Format(#"Provider=vfpoledb.1;data source={0}; TableType=vfp;", folderPath);

Related

Azure DevOps Pipeline Running EF Core Migrations with Managed Identity

Recently I migrated an old project to use Managed Identity in order to access an Azure SQL Server. This works fine on both the deployed Azure App Service and when running locally. The problem now is we have an Azure DevOps Pipeline for CI/CD and one of the tasks involves running the database migrations. After my changes the migrations task is failing and I can only assume it is because it's unable to obtain an Access Token, although the output, even with the verbose setting enabled, doesn't really give me much of a clue.
Some background on what I've done so far.
The pipeline has a valid service principal connection, currently the connection only has the user_impersonation delegated permission. Not sure if I need to add anything else here.
The service connection is a member of a custom DevSqlAdmins Active Directory group
The DevSqlAdmins group is set as a Contributor to my SQL server.
Finally there is the database user devsqladmins created as an External Group that should be tied to the Active Directory group.
Here is the output from my DevOps Pipeline job for running the migration.
Starting: Run Migrations
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.212.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents: shell
dotnet ef database update --project MY_PROJECT.Models/MY_PROJECT.Models.csproj -v
========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\0dca2055-13bb-4bf3-b01f-171c32526237.cmd""
Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.100
Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Using project 'D:\a\1\s\MY_PROJECT.Models\MY_PROJECT.Models.csproj'.
Using startup project 'D:\a\1\s\MY_PROJECT.Models\MY_PROJECT.Models.csproj'.
Writing 'D:\a\1\s\MY_PROJECT.Models\obj\MY_PROJECT.Models.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\VssAdministrator\AppData\Local\Temp\tmp9BBC.tmp /verbosity:quiet /nologo D:\a\1\s\MY_PROJECT.Models\MY_PROJECT.Models.csproj
Writing 'D:\a\1\s\MY_PROJECT.Models\obj\MY_PROJECT.Models.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\VssAdministrator\AppData\Local\Temp\tmp9FF3.tmp /verbosity:quiet /nologo D:\a\1\s\MY_PROJECT.Models\MY_PROJECT.Models.csproj
Build started...
dotnet build D:\a\1\s\MY_PROJECT.Models\MY_PROJECT.Models.csproj /verbosity:quiet /nologo
D:\a\1\s\Nex-Core.Utilities\Helpers\AzureHelper.cs(66,46): warning CS0168: The variable 'ex' is declared but never used [D:\a\1\s\Nex-Core.Utilities\Nex-Core.Utilities.csproj]
D:\a\1\s\Nex-Core.Utilities\Helpers\AzureHelper.cs(123,30): warning CS0168: The variable 'ex' is declared but never used [D:\a\1\s\Nex-Core.Utilities\Nex-Core.Utilities.csproj]
D:\a\1\s\Nex-Core.Utilities\Helpers\AzureHelper.cs(277,30): warning CS0168: The variable 'ex' is declared but never used [D:\a\1\s\Nex-Core.Utilities\Nex-Core.Utilities.csproj]
CSC : warning CS8032: An instance of analyzer Microsoft.EntityFrameworkCore.InternalUsageDiagnosticAnalyzer cannot be created from C:\Users\VssAdministrator\.nuget\packages\microsoft.entityframeworkcore.analyzers\7.0.3\analyzers\dotnet\cs\Microsoft.EntityFrameworkCore.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [D:\a\1\s\MY_PROJECT.Models\MY_PROJECT.Models.csproj]
Build succeeded.
D:\a\1\s\Nex-Core.Utilities\Helpers\AzureHelper.cs(66,46): warning CS0168: The variable 'ex' is declared but never used [D:\a\1\s\Nex-Core.Utilities\Nex-Core.Utilities.csproj]
D:\a\1\s\Nex-Core.Utilities\Helpers\AzureHelper.cs(123,30): warning CS0168: The variable 'ex' is declared but never used [D:\a\1\s\Nex-Core.Utilities\Nex-Core.Utilities.csproj]
D:\a\1\s\Nex-Core.Utilities\Helpers\AzureHelper.cs(277,30): warning CS0168: The variable 'ex' is declared but never used [D:\a\1\s\Nex-Core.Utilities\Nex-Core.Utilities.csproj]
CSC : warning CS8032: An instance of analyzer Microsoft.EntityFrameworkCore.InternalUsageDiagnosticAnalyzer cannot be created from C:\Users\VssAdministrator\.nuget\packages\microsoft.entityframeworkcore.analyzers\7.0.3\analyzers\dotnet\cs\Microsoft.EntityFrameworkCore.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [D:\a\1\s\MY_PROJECT.Models\MY_PROJECT.Models.csproj]
CSC : warning CS8032: An instance of analyzer Microsoft.EntityFrameworkCore.UninitializedDbSetDiagnosticSuppressor cannot be created from C:\Users\VssAdministrator\.nuget\packages\microsoft.entityframeworkcore.analyzers\7.0.3\analyzers\dotnet\cs\Microsoft.EntityFrameworkCore.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [D:\a\1\s\MY_PROJECT.Models\MY_PROJECT.Models.csproj]
5 Warning(s)
0 Error(s)
Time Elapsed 00:03:18.85
Build succeeded.
dotnet exec --depsfile D:\a\1\s\MY_PROJECT.Models\bin\Debug\net6.0\MY_PROJECT.Models.deps.json --additionalprobingpath C:\Users\VssAdministrator\.nuget\packages --additionalprobingpath "C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages" --additionalprobingpath "C:\Program Files (x86)\Microsoft\Xamarin\NuGet" --runtimeconfig D:\a\1\s\MY_PROJECT.Models\bin\Debug\net6.0\MY_PROJECT.Models.runtimeconfig.json C:\Users\VssAdministrator\.dotnet\tools\.store\dotnet-ef\7.0.3\dotnet-ef\7.0.3\tools\net6.0\any\tools\netcoreapp2.0\any\ef.dll database update --assembly D:\a\1\s\MY_PROJECT.Models\bin\Debug\net6.0\MY_PROJECT.Models.dll --project D:\a\1\s\MY_PROJECT.Models\MY_PROJECT.Models.csproj --startup-assembly D:\a\1\s\MY_PROJECT.Models\bin\Debug\net6.0\MY_PROJECT.Models.dll --startup-project D:\a\1\s\MY_PROJECT.Models\MY_PROJECT.Models.csproj --project-dir D:\a\1\s\MY_PROJECT.Models\ --root-namespace MY_PROJECT.Models --language C# --framework net6.0 --working-dir D:\a\1\s --verbose
Using assembly 'MY_PROJECT.Models'.
Using startup assembly 'MY_PROJECT.Models'.
Using application base 'D:\a\1\s\MY_PROJECT.Models\bin\Debug\net6.0'.
Using working directory 'D:\a\1\s\MY_PROJECT.Models'.
Using root namespace 'MY_PROJECT.Models'.
Using project directory 'D:\a\1\s\MY_PROJECT.Models\'.
Remaining arguments: .
Using configuration file 'D:\a\1\s\MY_PROJECT.Models\bin\Debug\net6.0\MY_PROJECT.Models.dll.config'.
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider in assembly 'MY_PROJECT.Models'...
Finding Microsoft.Extensions.Hosting service provider...
No static method 'CreateHostBuilder(string[])' was found on class 'Program'.
No application service provider was found.
Finding DbContext classes in the project...
Found DbContext 'MY_PROJECTDBEntities'.
Using context 'MY_PROJECTDBEntities'.
Finding design-time services referenced by assembly 'MY_PROJECT.Models'...
Finding design-time services referenced by assembly 'MY_PROJECT.Models'...
No referenced design-time services were found.
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.SqlServer'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.SqlServer'.
Finding IDesignTimeServices implementations in assembly 'MY_PROJECT.Models'...
No design-time services were found.
Creating DbConnection.
Created DbConnection. (90ms).
Migrating using database 'development-production-copy' on server 'tcp:MY_PROJECT.database.windows.net'.
Opening connection to database 'development-production-copy' on server 'tcp:MY_PROJECT.database.windows.net'.
An error occurred using the connection to database 'development-production-copy' on server 'tcp:MY_PROJECT.database.windows.net'.
'MY_PROJECTDBEntities' disposed.
Disposing connection to database 'development-production-copy' on server 'tcp:MY_PROJECT.database.windows.net'.
Disposed connection to database '' on server '' (1ms).
Microsoft.Data.SqlClient.SqlException (0x80131904): A task was canceled.
---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Azure.Identity.AzureCliCredential.RequestCliAccessTokenAsync(Boolean async, TokenRequestContext context, CancellationToken cancellationToken)
at Azure.Identity.AzureCliCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken)
at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex, String additionalMessage)
at Azure.Identity.AzureCliCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken)
at Azure.Identity.AzureCliCredential.GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
at Azure.Identity.DefaultAzureCredential.GetTokenFromSourcesAsync(TokenCredential[] sources, TokenRequestContext requestContext, Boolean async, CancellationToken cancellationToken)
at Azure.Identity.DefaultAzureCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken)
at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex, String additionalMessage)
at Azure.Identity.DefaultAzureCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken)
at Azure.Identity.DefaultAzureCredential.GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
at Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.AcquireTokenAsync(SqlAuthenticationParameters parameters) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\src\Microsoft\Data\SqlClient\ActiveDirectoryAuthenticationProvider.cs:line 160
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.<>c__DisplayClass147_1.<<GetFedAuthToken>b__1>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:line 2404
--- End of stack trace from previous location ---
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.GetFedAuthToken(SqlFedAuthInfo fedAuthInfo) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:line 0
at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\ProviderBase\DbConnectionPool.NetCoreApp.cs:line 18
at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\ProviderBase\DbConnectionPool.cs:line 779
at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\ProviderBase\DbConnectionPool.cs:line 1759
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\ProviderBase\DbConnectionPool.cs:line 1162
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\ProviderBase\DbConnectionPool.cs:line 1130
at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\ProviderBase\DbConnectionFactory.cs:line 122
at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Common\src\Microsoft\Data\ProviderBase\DbConnectionInternal.cs:line 341
at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Common\src\Microsoft\Data\ProviderBase\DbConnectionClosed.cs:line 39
at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlConnection.cs:line 1844
at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlConnection.cs:line 1333
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.OpenDbConnection(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.<>c__DisplayClass18_0.<Exists>b__0(DateTime giveUp)
at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__DisplayClass12_0`2.<Execute>b__0(DbContext _, TState s)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult](IExecutionStrategy strategy, TState state, Func`2 operation, Func`2 verifySucceeded)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.Exists(Boolean retryOnNotExists)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.Exists()
at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
ClientConnectionId:d6f7446e-be0f-491e-b450-168b30cd4b59
ClientConnectionId before routing:16fa382e-12b7-4748-9486-4bcf9e64f0dd
Routing Destination:b2cb5b1e94e5.tr274.eastus1-a.worker.database.windows.net,11042
A task was canceled.
##[error]Cmd.exe exited with code '1'.
Finishing: Run Migrations
I will add that the authentication method is specified in the connection string as
Server=tcp:my_project.database.windows.net;Initial Catalog=development;Persist Security Info=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication=\"Active Directory Default\"; So do I need to somehow obtain the access token myself, or does something need to be configured such that my DbContext class can fetch the access token from the pipeline's service principal connection.

COM class factory Error in Microsoft.Office.Interop [duplicate]

I am trying to convert a .xls file to an .xlsx file on the server-side using Microsoft.Office.Interop.Excel.Workbook class as follows:
workBook.SaveAs("FILENAME_HERE", XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
and I get the following error:
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)). : System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
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 CALLING_METHOD_IN_MY_LIBRARY_HERE...
The problem is that this error occurs only on the staging server; on my local machine it works fine.
Things that I have tried on the staging server:
**1) Run dcomcnfg open Component Services
2) Expand Component Services "->" Computer "->" My Computer "->" the DCOM configuration "
3) Find the "Microsoft Excel application."
4) Right to open the Properties dialog box
5) Clicked on the "Security" tab,
6) "Launch and Activation Permissions, configure permissions, have added permissions - Identity run under Adminstrator user (This User), Interactive User and Launching Users
7). Launch and activation permissions + Access Permissions + Configuration Permissions => added IIS_IUSRS + Network Service with Full Controll**
2.
Changed the build of the project that converts the .xls file from "Any CPU" to "x86" on my local machine and published this library on the server.
Did someone figured out how to fix this problem? I am struggling on fix this issue for 2 days now.
Using DCOMCNFG.exe. Open it and go to:
Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application.
Open the properties, select Identity tab and select the interactive user.
I found the solution elsewhere.
Doing the following did solve my problem:
Using DCOMCNFG.exe. Open it and go to: Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application. Open the properties, select Identity tab and select the interactive user.
BUT - the problem came back every few minutes !
After hours of trying to figure out the cause, I noticed my server had hundreds of opened WINWORD.EXE processes. This caused a memory issue which leaded to the exception from hresult 0x80080005 error.
Well, stupidly enough, I forgot to write the code to close the interop application. Once I fixed that, the error was gone.
doc.Close(false);
Marshal.ReleaseComObject(doc);
word.Quit();
Marshal.ReleaseComObject(word);
I found this article which talks more about this issue in depth If this helps,
error “80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))” could occur due to following reasons:
The machine has a high CPU load and the process takes a long time to
start and fails to execute the CoRegisterClassObjects() in less than
120 seconds.
The COM server doesn't register for the right class IDs.
The COM server is currently stopping and there is a race condition
between CoCreateInstance and the COM server stopping part.
There is a security problem in the way the COM server is started
(this page seems to suggest misspelled passwords or lacking the
"Login as Batch Job" privilege for "Run As.." COM servers, but
anyway I would suggest re-verifying this information for your
specific configuration)
https://blogs.msdn.microsoft.com/adioltean/2005/06/24/when-cocreateinstance-returns-0x80080005-co_e_server_exec_failure/
I fixed this issue with this solution:
right click on Component Services/Computers/DCOM Config/Microsoft Word97 - 2003 Document
properties/General Tab
set Authentication Level:None
TLDR; the fix for me is to disable AutoRecover from File -> Options -> Save,
then discard all autorecovered files. It would appear it's the volume of autorecover files which is the root cause.
Background
I cycle through a lot open / close /compute cycles. Periodically the C# app fails to open a workbook with the below error.
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
The app repeatedly throws this error and is stuck in this state until the AutoRecovered files are cleared from Excel.
Another symptom follows; when I try to open Excel app (as if to create a new workbook, not open an existing one), it takes a long time spinning cpu cycles. It opens eventually and there are tons of files listed in the Recovered files pane on the left.
I Close the pane using the button, all the files are then discarded. Re-opening Excel again after this procedure is near instant. The app runs fine again from hereon.
Same problem was solved for me by "allowing desktop interaction" for the service. (in tomcat6w config tool on Log On tab)
Start -> Run (Windows+R)
Type: dcomcnfg -32 (hit enter)
this should open Component Services
Expand Component Services, Computers, My Computer, DCOM Config
Scroll down to "Microsoft Excel Application"
Right Click, select properties, go to Security tab
Edit Access Permissions
Click Add
Type <Computer_Name>/IIS_IUSRS (or go to Locations, select computer name - if using domain, by default, it will search the domain and will not find IIS_IUSRS)
Make sure the check box for "Allow" is checked for "Local Access"
Click OK, Click OK again (no rebooting is necessary)
Windows Update will reset this ever single time
Try to add Thread.Sleep Method, such as Thread.Sleep(2000) for 2 seconds after workBook.open and workBook.SaveAs two methods. If your Excel file has a lot of formats, try to extend few more seconds.

Reading .xls (97-2003) files with ACE after oppening them with Excel 2013

We have been using Access Database Engine 2010 (V.14.0.4763.1000) for reading Excel (97-2003) .xls files from c# (.Net framework 4.0) with succesful results for a really long time. But now, after opening the files with Excel 2013, and saving them again in the same format (97-2003 .xls) we can't read the files anymore.
It gives us the following error:
External table is not in the expected format.
This doesn't happen when we open and save the files with Excel 2007 or 2010, only with 2013. We use the following connection string for reading the file:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 8.0;HDR=YES
where {0} is replaced by the file name and path. It seems Excel 2013 corrupts the 97-2003 file structure in some way that ACE doesn't understand. Is there any way we can fix this issue?
Just to be clear, the file format we need to read is always .xls (97-2003), we don't want to read .xlsx files (we can do this with no problem), but we need to use (97-2003) for compatibility with other systems.
Edit:
I made a very simple test program to illustrate, you can get it here:
https://www.dropbox.com/s/1ftw3emilnbuw6t/ExcelTest.rar
The .rar file contains:
ExcelReadingTest.exe (The Program)
Program.cs (The source code)
SavedFromExcel2007.xls (An example Excel file saved from Excel 2007 in 97-2003 format)
SavedFromExcel2013.xls (The same Excel file saved from Excel 2013 in 97-2003 format)
To run the example save all files in c:\temp and type on a cmd console:
C:\>cd c:\temp (Enter)
C:\temp>ExcelReadingTest SavedFromExcel2007.xls (Enter)
You´ll get:
1 Hello
2 World
3 Reading
4 Excel
Press Enter...
And if you type:
C:\temp>ExcelReadingTest SavedFromExcel2013.xls (Enter)
You´ll get this with Access Database Engine 2007 (12.0.6612.1000) installed:
System.Data.OleDb.OleDbException (0x80040E37): The Microsoft Access database eng
ine could not find the object 'Sheet1$'. Make sure the object exists and that yo
u spell its name and the path name correctly. If 'Sheet1$' is not a local object
, check your network connection or contact the server administrator.
en System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResul
t hr)
en System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARA
MS dbParams, Object& executeResult)
en System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
en System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Ob
ject& executeResult)
en System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behav
ior, String method)
en System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
en System.Data.OleDb.OleDbCommand.ExecuteReader()
en ExcelReadingTest.Program.Main(String[] args)
Press Enter...
Or you´ll get this with Access Database Engine 2010 (14.0.7015.1000) installed:
System.Data.OleDb.OleDbException (0x80004005): External table is not in the expe
cted format.
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString cons
tr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOpti
ons options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection o
wningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbC
onnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection ow
ningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection ou
terConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at ExcelReadingTest.Program.Main(String[] args) in c:\users\ivanm\documents\v
isual studio 2010\Projects\ExcelReadingTest\ExcelReadingTest\Program.cs:line 41
Press Enter...

Oracle oci.dll missing when running on MSTest agent

I'm trying to get some database related integration tests running on a MSTest test agent. We use c# and an oracle db with devart dotconnect.
Since we need to use indirect mode, I installed devart and an oracle client on the test agent.
The tests run smoothly when I execute them on my local machine. But when executed on the test agent (remotely), it can't find the client's oci.dll, which is a dependency somewhere:
System.IO.FileNotFoundException: Can not load Oracle client library oci.dll from home ..
Now, I have no idea why that happens. I checked the PATH environment variables already, but they seem fine. Any ideas why this works on my machine, but not when deployed to the test agent?
edit: added stacktrace within devart:
Devart.Data.Oracle.OracleHome.get_ClientVersion()
Devart.Data.Oracle.aw.a(Boolean A_0, Boolean A_1, OracleHome A_2, Boolean A_3)
Devart.Data.Oracle.OracleInternalConnection..ctor(aa connectionOptions, OracleInternalConnection proxyConnection)
Devart.Data.Oracle.cs.a(k A_0, Object A_1, DbConnectionBase A_2)
Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, k A_1, DbConnectionBase A_2)
Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection)
Devart.Common.DbConnectionFactory.a(DbConnectionBase A_0)
Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
Devart.Common.DbConnectionBase.Open()
Devart.Data.Oracle.OracleConnection.Open()
Thanks for the replies, got the right pointers. Apparently the problem occurs when a 64bit thread tries to load a 32bit OCI.DLL and vice versa. However, I played around with the test settings and build settings related to 32/64 things, but to no avail.
Anyway, I was able to solve the problem by additionally installing a 64-bit Oracle Client on the test agent. For some reason it seems that then the QTAgent thread finds the right OCI.DLL.
Faced the same problem in a console project. I fixed it by changing the compilation platform setting by going to
project properties -> Compilation -> Destination of the platform and selecting x86.

Cannot encrypt / decrypt SQLite database in .NET4

I am running Visual Studio 2010 on a Windows 7 x64. The app I'm writing is supposed to run on all platforms (AnyCPU). I'm able to encrypt/decrypt the database file if I'm using the System.Data.SQLite.dll either x86 version (sqlite-netFx40-static-binary-bundle-Win32-2010-1.0.77.0.zip) or x64 one (sqlite-netFx40-static-binary-bundle-x64-2010-1.0.77.0.zip).
I need my app to run on both platforms x86 and x64 (Any CPU project build setting). I've tried installing the ADO.NET 4.0 Provider (SQLite-1.0.67.1-vs2010-net4-setup.exe). I added the reference (right-click on project, Add Reference, .NET tab -> System.Data.SQLite) and ran the program. If I decrypt the file and try to encrypt by calling ChangePassword("myPass"), I get the following exception:
System.EntryPointNotFoundException was caught
Message=Unable to find an entry point named 'sqlite3_rekey' in DLL 'System.Data.SQLite.DLL'.
Source=System.Data.SQLite TypeName=""
StackTrace:
at System.Data.SQLite.UnsafeNativeMethods.sqlite3_rekey(IntPtr db, Byte[ key, Int32 keylen)
at System.Data.SQLite.SQLite3.ChangePassword(Byte[ newPasswordBytes)
at System.Data.SQLite.SQLiteConnection.ChangePassword(Byte[ newPassword)
at System.Data.SQLite.SQLiteConnection.ChangePassword(String newPassword)
at SQLiteTest.Database.Encrypt() in C:\SQLiteTest\Database.cs:line 166
Also, I've tried to open a connection using the SQLiteConnection object and I get two different exceptions in two different cases.
First, if the file is encrypted and I don't specify a password in the connection string I get this:
System.Data.SQLite.SQLiteException was caught
Message=File opened
that is not a database file file is encrypted or is not a database
Source=System.Data.SQLite ErrorCode=-2147467259
StackTrace:
at System.Data.SQLite.SQLite3.Prepare(SQLiteConnection cnn, String strSql, SQLiteStatement previous,
UInt32 timeoutMS, String& strRemain)
at System.Data.SQLite.SQLiteCommand.BuildNextCommand()
at System.Data.SQLite.SQLiteCommand.GetStatement(Int32 index)
at System.Data.SQLite.SQLiteDataReader.NextResult()
at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior
behavior)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
at System.Data.SQLite.SQLiteConnection.Open()
at SQLiteTest.Database.GetAllLanguages() in C:\SQLiteTest\Database.cs:line 216
Second, if I add the password parameter to the connection string, I get the System.EntryPointNotFoundException like the one above.
So, does anyone know a sure-fire way to work with encrypted SQLite database in a C# app on AnyCPU platform?
Thanks in advance!
Following Solution is a little bit dirty, but it may work, we didn't use encrypted database so i'm not 100% if that will work for you.
We downloaded both versions of sqlite dlls for x64 and x86 and placed them in different folders. We load them manually dependent on what platform application is currently running ( we check IntPtr.Size , from .net 4 there is a property in Environment class called Is64BitOperatingSystem) when we loaded assembly manually we get connection instance with
var sqliteConnectionType = assembly.GetType("System.Data.SQLite.SQLiteConnection");
(DbConnection)Activator.CreateInstance(sqliteConnectionType);
we don't use reference to any version of sqlite in our project.

Categories