ASP.net Oracle DataReader in C# - c#

I have an ASP.net appication in which it uses an ODP.net database connection. I have extracted the database handler into a dll file in order to extend its flexibility.
An error pops up occasionaly saying as follows:
Error 1 Assembly 'DatabaseConnection, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' uses 'Oracle.DataAccess, Version=4.112.2.0, Culture=neutral,
PublicKeyToken=89b483f429c47342' which has a higher version than referenced assembly
'Oracle.DataAccess, Version=2.112.2.0, Culture=neutral,
PublicKeyToken=89b483f429c47342' c:\Documents and Settings\Visual Studio
2010\Projects\DatabaseConnection\bin\Debug\DatabaseConnection.dll
Last time it happend, the error faded away automatically alone.
What is the reason for such error?

From the error look at the version number, your dll is expecting Oracle.DataAccess of Version=4.112.2.0 and i believe maybe in your GAC or bin you have a lower version 2.112.2.0.
Try to get the required version and this should be resolved.

Also - if you are using .Net 4.0 - you must use the 4.x assembly to be supported by Oracle.

Related

Errors and warnings seemingly related to application pool issues in IIS after framework upgrade

Some unexpected warnings and errors started appearing in my Soap Service after I had updated from .Net Framework 4.0 to 4.5.2 on Windows 7.
The errors all disappeared after I removed an old framework 2 application pool from IIS. I also removed all old application pools so that I only had 1 application pool for my project.
After this I was unable to reproduce the error by adding back a framework 2 application pool.
The issues I experienced and subsequently resolved where
[Issue 1: Warning]
The following assembly has dependencies on a version of the .NET
Framework that is higher than the target and might not load correctly during
runtime causing a failure
The complete error was
Severity Code Description Project File Line Suppression State
Warning The following assembly has dependencies on a version of the .NET
Framework that is higher than the target and might not load correctly during
runtime causing a failure: SBD.Common, Version=2.0.0.1, Culture=neutral,
PublicKeyToken=a3471ea16b9add4c. The dependencies are: mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089; System,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;
System.ServiceModel, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089; System.Data, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089; System.Xml,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;
System.Core, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089. You should either ensure that the dependent
assembly is correct for the target framework, or ensure that the target
framework you are addressing is that of the dependent assembly.
**
[Issue 2 Error]
CS1502 The best overloaded method match for ( mymethod ) has some invalid arguements
In the code
[SoapHeader("CoreHeader")]
public bool QueueDeleteDesigns(int itemId, int[] designIDs)
{
CheckCoreHeader();
string s = string.Join(",", designIDs);
// etc
Intellisense also showed
The type 'IQueryable' is defined in an assembly that is not referenced. You
must add a reference to assembly 'System.Core, Version =4.0.0.0
**
[Issue 3 Warning]
warning CS1684: Reference to type 'System.Tuple`2' claims it is defined in 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll', but it could not be found
You probably won't need this step but just for completeness:
Check your applicationhost.config file - if you manually added an entry to it, make sure it reads this for your site:
<application path="/" applicationPool="Clr4IntegratedAppPool">
This would most probably fix the issue:
In your web.config file, make sure your compilation tag has the framework version and a valid temporary directory path which is accessible by your IIS_IUSRS or IIS_WPG usergroups (read more about user groups here - https://learn.microsoft.com/en-us/iis/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis):
<compilation debug="True" strict="False" explicit="True" targetFramework="4.0" tempDirectory="C:\inetpub\temp\">
I spent a whole day troubleshooting these 3 issues , and I am unclear as to what the exact fix was, because after fixing the issues I was unable to reproduce them.
I think it was to do with cleaning up old application pools in IIS.

.NET Core and Azure Functions - build error System.Runtime 4.2.0.0

I'm creating Azure Functions for .NET Core, following the documentations on Microsoft and Github
So the key for using all functionality, and the publish functions from VisualStudio is package microsoft.net.sdk.functions.
However, after adding this nuget, I get the following build error
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified
File name: 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at System.Reflection.RuntimeA...
[...]
file:///C:/Users/Stefan/.nuget/packages/microsoft.net.sdk.functions/1.0.7/tools/net46/
[...]
Although the package comes with .netstandard 2.0 support, it references the net46 folder and ends up in that error...
Any ideas how to solve this?

'Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I am a newbie and just created a new project of type: ASP.NET Core Web Application (.NET Core) and let VS preload all the defaults. I changed nothing, except set index.cshtml the startup. It built ok, but has a run-time error of:
System.IO.FileNotFoundException occurred
HResult=0x80070002
Message=Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Call Stack (last item):
ntdll.dll!NtWaitForSingleObject() Unknown
What is happening here, and how can it be fixed?
Using Visual Studio Installer, selecting the Repair option solved the problem.

Could not load file or assembly System, Version=2.0.5.0 in .NET 4 MVC 4 application

Been searching for ages, can't find anything helpful. Here is the exception I'm getting:
Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Stack Trace:
[FileLoadException: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)]
StructureMap.Graph.PluginGraph..ctor() in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Graph\PluginGraph.cs:41
StructureMap.PluginGraphBuilder..ctor() in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\PluginGraphBuilder.cs:22
StructureMap.InitializationExpression..ctor() in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\InitializationExpression.cs:22
StructureMap.ObjectFactory.Initialize(Action`1 action) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\ObjectFactory.cs:47
...
This applications works fine on the test server but is throwing this exception on the production server. As you can see, the StructureMap code is what is causing the exception.
I had to convert this app to .NET 4 from 4.5 because 4.5 wasn't installed on the production server. After the conversion, the app still works fine on my local machine and the test server.
I have already set the Copy Local to True for the System assembly, but since the referenced version is 4.0.0.0 and not 2.0.5.0, I this made no difference.
Let me know if any more info is needed. Any help you may be able to provide is appreciated.
Make sure your .NET framework is patched. Microsoft released patches to .NET to allow Portable Class Libraries to properly find the appropriate runtime (KB2468871). If you are seeing the above exception (or something like it), it means you're missing the latest .NET framework patches.
Edit the web.config file to remove the reference, which is not required for normal operation:
1 - Open the web.config file in the root of your site
2 - Find the following line and comment it out():xxxxx-is your assembly name.
<add assembly="xxxxx", Version=2.0.5.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
3 - Save and close the web.config file and try again
I found that it was the "await" and "async" that where giving me trouble.
I had Windows XP SP3 with only .NET 4.0, but had to update it to .NET 4.0.3 using KB2600211 - this wasn't updated automatically through Windows Update when .NET 4.0.3 came out because the computer is off-grid.
This is the link to the update:
https://www.microsoft.com/en-us/download/details.aspx?id=29053
I just want to share another solution from here that solved the problem on my development machine: installing Silverlight 5 SDK (only 11.2MB at the time of writing this post) was enough to make everything working.
Install Microsoft® Silverlight® 5 SDK from the following link. It resolves and works fine for me.
SDK download
Starting from a machine configuration that only had VS2017 and Silverlight 5 SDK on it, I installed VS2015 on top of that. This is when I started getting the System.Core and System.Windows problems.
When I uninstalled VS2015 and re-installed Silverlight 5 SDK, these problems went away.

Addind assembly to DB

I've got a problem, I want to run scalar-valued-function that will run my C# method that evaluate mathematical expression from text. To evaluate expression I want to use Jace.dll (Jace.NET 0.8.4). When trying to add this dll to database assebly I've got this errors:
Assembly 'Jace' references assembly 'mscorlib, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.
Could not deploy package.
Error SQL72014: .Net SqlClient Data Provider: Msg 10300, Level 16, State 1, Line 24 Assembly 'Jace' references assembly 'mscorlib, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e.', which is not present in the current database.
SQL Server attempted to locate and automatically load the referenced assembly
from the same location where referring assembly came from, but that operation has failed
(reason: version, culture or public key mismatch). Please load the referenced assembly into the current database and retry your request.
Can someone help me solve this one ? I know that database have different version of mscorlib than Jace is needed. Because db is using newer one. Should I just insert this 2.0.5 version to db ?

Categories

Resources