Missing method 'instance void MYDLLNAME ADODB.Fields...' - c#

Have rewritten some parts of the application from VB.Net to C#. Everything is working as expected for all but one user. This user is getting this error message:
Error: Missing method 'instance void MYDLLNAME ADODB.Fields::Append(string,valuetype ADODB.DataTypeEnum,int32,valuetype ADODB.FieldAttributeEnum,object)' from class 'ADODB.InternalFields'
Is there a component potentially missing on the end user machine and is there a way to solve this or is it best to go away from ADODB.Recordset to ADO.Net Dataset?
Have seen the following questions, but they do not really solve my problem. Not upgraded framework, was already 4.5, VS 2017 used.
Strange error appending fields to recordset in VS2010 after converting to .NET 4
https://social.msdn.microsoft.com/Forums/en-US/f84cdc9c-f684-46d6-9b6f-757d047b00d5/fieldsappend?forum=Vsexpressvb
P.S. Using COM is not an option in my case.

Problem solved by setting properties of reference to ADODB in the project to:
Embed Interop = false
Copy Local = true
These are inverted defaults.

Related

How to fix 'JsonSerializerSettings' fail to access field 'DefaultContext'

Since I pull my project from GitHub and attempt to run my app the problem keep happening when it refers to Json.net when trying to serialize anything. Originally it was at version 11 when the error showed up, then I tried to downgrade to version 8 and it still persists. So, I upgrade to latest on 12.0.1 but the problem still not going away
The code is nothing but Newtonsoft.Json.JsonConvert.SerializeObject(data)
And no matter what type of data it is it always thrown
FieldAccessException: Attempt by method
'Newtonsoft.Json.JsonSerializerSettings..cctor()' to access field
'Newtonsoft.Json.JsonSerializerSettings.DefaultContext' failed.
I even tried to construct the JsonSerializerSettings on my own and that still happens.
Will this answer help you?
Basically, in order to workaround this problem you need to make sure "Enable the Visual Studio hosting process" is unchecked in your project's settings under Debug.
This error may occur if the code is running under partial trust. Following link can help more in providing error description:
https://learn.microsoft.com/en-us/dotnet/api/system.methodaccessexception?redirectedfrom=MSDN&view=netframework-4.7.2
Previously, I have encountered this error if the code has restricted access like private, protected or internal methods. As per MSDN:
This exception is thrown in situations such as the following:
A private, protected, or internal method that would not be accessible from normal compiled code is accessed from partially
trusted code by using reflection.
A security-critical method is accessed from transparent code.
The access level of a method in a class library has changed, and one or more assemblies that reference the library have not been
recompiled.

I get a COM exception after adding methods to a COM Interface [The procedure number is out of range]

I had a working C# [DOT NET 4.6.1] project which used COM interfaces. After I added two methods to an interface, I started getting the exception "The procedure number is out of range. (Exception from HRESULT: 0x800706D1)" . This has never happened previously, and I have always been able to change COM interfaces and classes without any issues.
I found the following in MSDN support at https://msdn.microsoft.com/en-us/library/ms838933.aspx
"Contact the supplier of the running distributed application. There is a version control problem in the application that can only be fixed by the application supplier (procedures were added to an .IDL file without changing the version number)."
I tried changing the GUID of the interface, but then the I got a cast exception when trying to use the object , saying no such interface supported.
Is this a VS2017 issue (Compile does not update the build)or is it something else?
Please help!
Sagar

C# convert ApplicationSettings to a interface class in runtime

during migration of .net framework from 4.6 to 4.6.2 on VS 2015 for one of the web related projects ran into the following problem.
The application settings are split into 2 for testing and production.
The switch used to happen in run time based on value of key value pair in a ini file.
Additional properties were added in run time by passing values from a different process.
The conversion into interface was simple by simple assignment.
For ex:
IInterface sInterface = Properties.Settings.Default;
Unfortunately this doesnt work any more after upgradation to .net 4.6.2.
Ends up with the error : cannot implicitly convert type "Properties.Settings.Default" to IInterface.
Explicit casting doesnt work either.
Tried following:
System.Convert.ChangeType ended up with System.InvalidCastException.
Any way this can be done?

SagePay .Net Integration Kit - Error when returning NOTAVAILABLE value for 3dSecureStatus

I have implemented SagePay payment using the Form Integration. My implementation is based on the .Net integration kit supplied by SagePay which has all been good.
Recently we have enabled 3D Secure and have encountered an issue when the value of 3DSecureStatus returns a value of NOTAVAILABLE.
It would seem that when the NOTAVAILABLE value is returned, an error is thrown within the call to the ConvertToSagePayMessage() method on the SagePayIntegration class within the assembly SagePay.IntegrationKit.DotNet.dll.
Specifically, this error occurs when the value is being parsed to the ThreeDSecureStatus enum. This enum does not have a value for NOTAVAILABLE to be able to parse to, hence the error.
I have put a fix in for this for the moment to get this working for now. This fix replaces the NOTAVAILABLE value with NONE, so this now parse to a valid enum value. This is done just before the call to ConvertToSagePayMessage()
cryptDecoded = cryptDecoded.Replace("3DSecureStatus=NOTAVAILABLE", "3DSecureStatus=NONE");
I was just wondering why the ThreeDSecureStatus enum does not have a value for NOTAVAILABLE, as NOTAVAILABLE is one of the values that it is expected to return, which is outlined in the Form Integration Protocol guide supplied by SagePay. And was hoping to implement a more robust fix, rather than the string replace.
The problem is that the integration kit contains a bug in that the enum for the 3DSecure status is missing a value for NOTAVAILABLE. SagePay have even told me this:
Unfortunately this is a known issue with the .NET kit but there is no fix as of yet.
So there are three possible ways to fix this.
Either modify the decoded response from the server to change the value of the 3DSecureStatus value to NONE (as written in the question.)
Use a version of the Integration Kit that has had the fix applied. You can ask SagePay for the code (they seem perfectly willing to provide it free of charge) and add in NOTAVAILABLE as an enum value in the ThreeDSecureStatus.cs file:
public enum ThreeDSecureStatus
{
NONE,
OK,
NOAUTH,
CANTAUTH,
NOTAUTHED,
ATTEMPTONLY,
NOTCHECKED,
INCOMPLETE,
MALFORMED,
INVALID,
ERROR,
NOTAVAILABLE //<--- Add this
}
I have already gone through the process of fixing the bug and have uploaded it to a GitHub repository. Feel free to take the code from there. I have also updated the project to use C#6 and as such you will need to use Visual Studio 2015 or higher to use it. If you do need to use an older version, you could start with the original files from the first commit to the repository.

Unable to use async/await in LINQPad - "Invalid token {after async} in .."

I wanted to try the "new" async/await (yeah, I'm late to the party) so I fired up LINQPad 4.5.1 which is currently the latest non-beta. After switching to "C# Program" and input the following code, sans comment;
// "Invalid token 'void' in class, struct, or interface member declaration"
// - But compiles with `async` removed
async void foo () {
}
void Main()
{
foo();
}
But it .. "doesn't work" as indicated.
This error seems to indicate that LINQPad is using C#4 and not C#5 although the website does say "LINQPad supports everything in C# 5.0 and Framework 4.x" and others don't seem to have this problem.
What causes this error, and how can it be resolved?
Even if this is not the solution for this particular issue, it may come handy for people like me that arrived to this question looking a fix for a compile error with the Task<T> return type because I was missing a using. The way to add it on LinqPad is pressing F4 > Namespace Imports tabs and adding at the bottom of the list System.Threading.Tasks then press Ok.
You can also set this new list as the default for the new queries pressing Set as default for new queries
Other way to access this tab is by the top menu Query > Namespace Imports
Well, that was .. silly of me. The current machine had .NET 4 - not 4.5 - installed.
After installing .NET 4.5 "it works".

Categories

Resources