system.reflection.targetinvocationexception in xamarin - c#

I've created an android app via Xamarin. the app is supposed to connect to sql server through an asmx webservice. I've tested the asmx in my browser and it works well. but the problem is that when I try the app on my android device (not emulator), the following exception occurs:
system.reflection.targetinvocationexception: 'an exception occurred during the operation, making the result invalid. check innerexception for exception details.'.
now there is a warning that I got after I built my project and it is as follows:
warning XA0105: The $(TargetFrameworkVersion) for System.EnterpriseServices (v10.0) is greater than the $(TargetFrameworkVersion) for your project (v9.0). You need to increase the $(TargetFrameworkVersion) for your project.
so i'm guessing the exception is due to this warning. I tried increasing the target framework of my project but I got more warnings and errors because api level 29 of the new target framework doesn't seem available. so my question is, is the exception truly the result of the warning? if not what is the solution for such a warning?

Related

XSP/Mono: preventing "Warning as Error" exceptions

I'm running an ASP.NET v4.8 project under Mono.
Actually, I'm doing it by using the Mono's standalone web server - XSP.
When I try to start the application in browser, I'm getting this annoying exception:
System.Web.Compilation.CompilationException:
error CS1685: Warning as Error: The predefined type System.Runtime.CompilerServices.AsyncMethodBuilderAttribute' is defined multiple times. Using definition from mscorlib.dll'"
For each project in my solution, I set the "Treat warnings as errors" option to "None" - but it still doesn't work.
I suspect that the "Warning as Error" exceptions come from the XSP program, but not sure.
I can say that I able to load the application when I'm deleting 2 files - System.Memory.dll and System.Threading.Tasks.Extensions.dll which both are used by npgsql.dll.
But when I try to use Postgres in the application, I'm getting another exception which says that the 2 files are missing...
Since the project works fine on IIS, my question is:
how do I stop those annoying "Warning as Error" exceptions?
Thanks for any answer!

'Oracle.DataAccess.Client.OracleConnection' threw an exception, WinForms Application

I have a WinForms application in a .NET Framework 4.5.2 and an Oracle 10g database. This application works perfectly fine when I debug it using VS 2017, but when I deploy it as a ClickOnce application [using ClickOnce Deployment Manifest] it does not work and I keep getting the following error.
Image of the error upon connecting
relevant error text follows:
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleCommand' threw an exception. ---> Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client
at Oracle.DataAccess.Client.OracleInit.Initialize()
at Oracle.DataAccess.Client.OracleCommand..cctor()
--- End of inner exception stack trace ---
It also runs perfectly fine when running the it from bin/Release folder, how can I make so that my deployed application runs like my local .exe in my repo.
And an additional piece of info, this WPF application is just a menu so that it runs my other WinForms applications, they work perfectly fine even when published, I have ensured that all applications are targeting an (x86) architecture and that all the ClickOnce settings are the same, to no avail.
Or can I even recreate the error when debugging so that I can fix? I tried forcing 64 - bit mode
(since that is what my machine is) in the properties of the project, but it does not even load. In the ClickOnce application it loads to the log-in page, but messes up when establishing a connection after the user has entered their credentials.
This is my first post so please fell free to request any more info and let me know if I have been unclear in anyway.
Thank you for the help in advance !
The issue has been resolved, but if anyone else come across it here is the solution, you have to find and add the appropriate DLL's manually into your project. I guess as mentioned in other answers, when the error says "...Client is not compatible..." it can also mean that the appropriate files do not exist.

Dynamics CRM 2011 SyncWorkflowExecutionPlugin unable to find assembly

A strange error suddenly cropped up on our Dynamics CRM 2011 server - a specific plugin assembly can not be found when the plugin execution is triggered through a workflow process, with the error:
[Microsoft.Crm.ObjectModel: Microsoft.Crm.ObjectModel.SyncWorkflowExecutionPlugin]
[324f29aa-6082-ea11-80ee-005056837add: ]
Starting sync workflow 'workflow name', Id: 2d4f29aa-6082-ea11-80ee-005056837add
Sync workflow 'workflow name' terminated with error 'The type initializer for '<Module>' threw an exception.'
And exception stack trace ultimately leads to:
Inner Exception: <CrtImplementationDetails>.ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.
at <CrtImplementationDetails>.ThrowModuleLoadException(String errorMessage, Exception innerException)
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
at .cctor()
Inner Exception: System.Runtime.Serialization.SerializationException: Unable to find assembly 'AssemblyName, Version=8.75.0.267, Culture=neutral, PublicKeyToken=4e4051c21cef725b'.
The assembly is present on the server, version, culture, and public key token all match. Oddly enough the plugin steps work fine when the execution is triggered directly through a create/update/etc request - it's only when the execution is triggered through a workflow that the error occurs. And by triggered through a workflow I don't mean running code activity from that assembly, I mean a situation like:
Entity is created
OnCreate plugin from Assembly1 runs without issues
Workflow runs that updates a related entity, triggering OnUpdate plugin from Assembly1 - ERROR
This issue cropped up initially after a server restart. Another restart fixed it temporarily, until two days later it started happening again. We've tried everything we can think of - updating the assembly, unregistering/re-registering it, restarting all services, restarting the server again. Does anyone have any idea what might be the cause of this and how to fix it?
We discovered the issue was caused by a Windows update that had been applied before the initial restart, which had installed .NET framework v4.8 on the server. Although the application was still using an older version, apparently just having v4.8 installed was enough to cause errors. Reverting back to an earlier .NET version fixed the problem.
I am not certain what is the exact technical reason for this - seems to be something related to App Domains (https://learn.microsoft.com/en-us/dotnet/api/system.appdomain?view=netframework-4.8). But if you encounter a similar issue, check your .NET framework version.

TFS 2013 Throws Lib2GitSharp Error During Build/Deploy (Intermittent)

For a while now, I have been having an issue with Team Foundation Server build/deploy process throwing the following error intermittently:
Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at LibGit2Sharp.Core.NativeMethods.git_threads_init()
at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor()
at LibGit2Sharp.Core.NativeMethods..cctor()
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.NativeMethods.RemoveHandle()
at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject.Finalize()
Exception Message: MSBuild error 255 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
This problem is very intermittent and it can be bypassed by simply retrying the build. Has anyone else run into this? Any solutions?
I know it is a little bit late for answer but it might help someone else
answer by Buck Hodges
We have now gotten to the bottom of this issue after debugging it with Manoj and customer support. It affected gated checkin of continuous delivery of Azure deployments as part of the build process when using the Azure SDK 2.5 or older. The workaround is to add /p:GenerateBuildInfoConfigFile=false to the msbuild arguments in your build definition. We are working on updating the build VM in production, but that will take 24-48 hours to propagate to all build pools.
You might want to read more in context here
https://social.msdn.microsoft.com/Forums/en-US/5a0d1950-1367-41a6-9171-676a0d0e93c1/tfs-online-getted-checkin-build-failures-vs-online-tfs-online-team-need-to-look-into-it?forum=TFService
Alternative solution based on comments
If you have VS installed on your build server, make sure you have opened it and licensed it. by #Phill
Strangely enough for me, I was getting the same error in the build logs:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\BuildInfo\Microsoft.VisualStudio.ReleaseManagement.BuildInfo.targets (147): The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
I was able to simply RETRY the build, and it did not fail on the second try. So for me it was a transitory build issue.
Although late to the party, experienced this error recently and while the solution marked as the answer worked for that build, the error was fixed (and the switch removed) when Visual Studio 2012 was upgraded to Visual Studio 2015 Update 3 on the build server which was running TFS 2015 Update 3.
I hit this after I had upgraded my TFS 2013 XAML build machine to TFS 2015.
I had also changed the user that TFS 2015 XAML build used to run the build (service.
The Fix:
I had to log into the TFS 2015 XAML build machine as that new user and launch VS (I was using VS2013).
It ran through it's first time launch questions and setup.
I still saw the Lib2GitSharp Error issue sometimes after that.
Then I also logged VS (on the TFS 2015 XAML build machine) into a valid VS account.
I have not seen the Lib2GitSharp Error since and I never used the /p:GenerateBuildInfoConfigFile=false option.
I resolved this error by adding the build account to the local administrators group on the build machine.

The pre-application start initialization method Start on type PreApplicationStartCode threw an exception

I have created a new WebMatrix-based website in Visual Studio 2013 Ultimate and added DB First EF ADO.NET to the site.
I have WebPages 3 installed, and .NET Framework is 4.5.
However, when I try to debug/Build the solution, it throws this error:
Error 1 The pre-application start initialization method Start on type
System.Web.WebPages.Administration.PreApplicationStartCode threw an
exception with the following error message: Attempt by security
transparent method
'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()'
to access security critical method
'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly,
System.String)' failed..
The only result that appears for this error in Google is http://craigwilson.id.au/2014/03/18/azurewap-system-methodaccessexception-attempt-by-security-transparent-method/#comment-1308 however, the solution on that page is to install WebHelpers via Package Manager console. This solution did not fix it for me.
Why am I getting this error and how can I fix it?

Categories