Regions/Locales and Pulling DateTimes( From Strings) from a Database - vb.net

I've been having several problems lately with clients that are using a different Windows Region setting than I am. I cannot seem to find a way to fix it. The error is as follows:
The type initializer for 'InventoryDataTable' threw an exception. ---> System.TypeInitializationException: The type initializer for 'InventoryDataTable' threw an exception. ---> System.FormatException: String was not recognized as a valid DateTime.
The error occurs when users load the application and their region settings do not match my own. The application loads up a dataset and attempts to receive a small amount of data before allowing the user to log in. When this is removed, the problem occurs immediately after the user logs in to the app.
I cannot seem to find the proper settings to force the user to use either my Region, or to allow the application to figure it out on it's own...
Exact error:
System.InvalidOperationException: An error occurred creating the form. See Exception.InnerException for details. The error is: The type initializer for 'InventoryDataTable' threw an exception. ---> System.TypeInitializationException: The type initializer for 'InventoryDataTable' threw an exception. ---> System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.DateTime.Parse(String s)
at Invasion_3042_v2.INVDataSet.InventoryDataTable..cctor() in C:\Users\Tdata\Desktop\I2.original\Invasion 3042 v2\INVDataSet.Designer.vb:line 7588
--- End of inner exception stack trace ---
at Invasion_3042_v2.INVDataSet.InventoryDataTable..ctor()
at Invasion_3042_v2.INVDataSet.InitClass() in C:\Users\Tdata\Desktop\I2.original\Invasion 3042 v2\INVDataSet.Designer.vb:line 4296
at Invasion_3042_v2.INVDataSet..ctor() in C:\Users\Tdata\Desktop\I2.original\Invasion 3042 v2\INVDataSet.Designer.vb:line 447
at Invasion_3042_v2.INV3042LOGIN.InitializeComponent() in C:\Users\Tdata\Desktop\I2.original\Invasion 3042 v2\INV3042LOGIN.Designer.vb:line 39
at Invasion_3042_v2.INV3042LOGIN..ctor() in C:\Users\Tdata\Desktop\I2.original\Invasion 3042 v2\INV3042LOGIN.vb:line 100
--- End of inner exception stack trace ---
at Invasion_3042_v2.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
at Invasion_3042_v2.My.MyProject.MyForms.get_INV3042LOGIN()
at Invasion_3042_v2.My.MyApplication.OnCreateMainForm() in C:\Users\Tdata\Desktop\I2.original\Invasion 3042 v2\My Project\Application.Designer.vb:line 35
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()

Posting the actual code causing the issue would have helped, but I can put forth a pretty good guess at what's going on.
Could it be that the date format being stored into your centralized database is always of a given format (maybe US?). If so, what is very likely happening is the following:
A date like 1/14/2012 is returned from a query to your database. The code running on your problem clients are parsing the date using perhaps European date regional settings. (In the EU and most other countries in the world 14-Jan-2012 is expressed as 14/01/2012 aka dd/MM/yyyy, not MM/dd/yyyy.
Try either specifying that you want to always use a known, base regional setting in your config file like this:
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" />
...or parse your dates using a specified culture setting like this to avoid defaulting to the local system setting that does not match your server-side expectations.
DateTime.Parse("1/14/2012", new CultureInfo("en-US")); // or whatever culture your server database expects...

Related

F# SqlDataProvider, "The type initializer for 'Main' threw an exception.'

I have been attempting to use the SqlProvider type provider on several different databases where I work. In Visual Studio, intellisense for these different DBs (of types MS Access, SQL Server, and an ODBC connection) all work as shown below:
I've even tried it on the Northwind example database:
It does not matter the connection I actually choose, they seem to all result in 2 exceptions when the code is actually run:
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'Main' threw an exception.
Source=SqlProviderTest2
StackTrace:
at Main.main(String[] _arg1) in C:\Users\***\source\repos\SqlProviderTest2\Program.fs:line 29
Inner Exception 1:
TypeInitializationException: The type initializer for '<StartupCode$SqlProviderTest2>.$Main' threw an exception.
Inner Exception 2:
FileLoadException: Could not load file or assembly 'System.Data.OleDb, Version=4.0.1.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
How is it possible that the intellisense can detect the DB but not work when the program is actually run? Is there a common fix for this?
(Using Visual Studio 2019 Professional, if that makes a difference.)

How to get Exception source “Activity Description name”

When exceptions occur in a UIPath project I have an email that is sent out with the exception info included. There seems to be an issue though where I can only see where the error occured by looking at the selector information such as:
Cannot find the UI element corresponding to this selector:
<html app='chrome.exe' title='Microsoft Dynamics GP' />
<webctrl aaname='Add' idx='1'
parentid='a00000000000000008549000000030009000000000001000000000000' tag='DIV' />
This info and the stack trace or any other info is not really helpful for quickly finding the source of the problem. I have looked through the UIPath documentation and forum and found only the this question, which seemed to point to using the exception.Source to show the name of the activity where the error occurred. exception.Source only returns “UiPath.Core.Activities” though instead of "Type into Copy Job# 'INPUT'" in the following example:
This obviously causes a big problem with exception handling. How can I easily return the source with each exception?
When your selector fails, you will end up with a new object of type UiPath.Core.SelectorNotFoundException. However, until the team at UiPath decides to add the Display Name into the inner exception, there is little you can do in this particular case.
Take the following example - the first line shows the Inner Exception, and the second one in red is essentially just the exception being rethrown. Note that only the latter one contains the Display Name property.
The Source itself will usually be of type UiPath.Core.Activities, but since this is just the type's name, we don't have any link to the faulting object. Here's what you can do:
Add some details to your exception. You don't want to do this for each activity, but you could have certain blocks of try-catches (example: logging into the system consists of three individual activites, and they reside in one block).
Rethrow the exception. That way the Display Name will end up in the execution log file.

Importing data from multi-value D3 database into SQL issues

Trying to use the mv.NET by bluefinity tools. Made some integration packages with it for importing data from a d3 multi-value database into MS SQL 2012 but seem to be having some trouble with the mapping.
For the VOYAGES table have some commentX fields in the D3 application that are acting quite unwieldy and the INSERT fails after a certain number of rows with the following message
>Error: 0xC0047062 at INSERT, mvNET Source[354]: System.Exception: Error #8: dataReader[0] = LTPAC002 ci.BufferColumnIndex = 52, ci.ColumnName = COMMGROUP(Error #8: dataReader[0] = LTPAC002 ci.BufferColumnIndex = 52, ci.ColumnName = COMMGROUP(The value is too large to fit in the column data area of the buffer.))
at mvNETDataSource.mvNETSource.PrimeOutput(Int32 outputs, Int32[] outputIDs, PipelineBuffer[] buffers)
at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostPrimeOutput(IDTSManagedComponentWrapper100 wrapper, Int32 outputs, Int32[] outputIDs, IDTSBuffer100[] buffers, IntPtr ppBufferWirePacket)
Error: 0xC0047038 at INSERT, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.The PrimeOutput method on mvNET Source returned error code 0x80131500.The component returned a failure code when the pipeline engine called PrimeOutput().The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.There may be error messages posted before this with more information about the failure.
The value is too large to fit in the column data area of the buffer. -> tried changing the input / outputs types but can't seem to get it right.
In the SQL table the columns are of type ntext.
In the .dtsx job the data type for the columns are of type Unicode String [DT_WSTR] with length 4000 , I guess these are auto-detected.
The import worked for other D3 files like this not sure why it fails for these comment fields.
Running the query on the mv.NET Data Manager ( on the d3 server) times out after 240 seconds so maybe this is the underlying issue?
Any ideas how to proceed? Thank you ~
Most like reason is column COMMGROUP does not have correct data type or some record in source do not fit in output type
To find error record (causing) you have to use on redirect row (property of component failing component ) and get the result set in some txt.csv /or tsv file .
then check data
The exception is being thrown from mv.NET so I suggest you call (or ask your reseller) to call Bluefinity support and ask them about this. You're paying for support, might as well use it. Those programs shouldn't be allowed to throw exceptions like that.
D3 doesn't export Unicode, that might be one issue. But if the Data Manager times-out then I suspect something is wrong in the connectivity into D3. Open a Connection Monitor from the Session Monitor and watch the connection when you make the request. I'm guessing it's either hanging or more probably it's falling into BASIC Debug.
Make sure all D3-side programs related to this are either all Flash-compiled, or all Not Flashed. Your app code will fall into Debug if it's not Flashed but MVNET.BP is.
If it's your program that's in Debug, fix it. If you're not sure which program it is, LIST-RUNTIME-ERRORS in DM.
If it's a MVNET.BP program, again work with Bluefinity. If you are using MVSP for connectivity then the Connection Monitor may be useless, you'll need to change that to an IP (Telnet) connection to see the raw data exchange.

SQL Server trace - translating PAGE information to actual resource

I am researching deadlocks that are happening in our application. I turned trace on for 1204, 1205 and 3605. I got the deadlock trace alright. But I am unable to figure out the resource it is deadlocking on. I have read many forums and they all say that the trace should contain something called a KEY/RID which would point to the resource in question. But my trace files does not contain KEY/RID at all. Instead it contains something called as PAGE.
For example,
06/30/2010 16:29:52,spid4s,Unknown,PAGE: 8:1:16512 CleanCnt:2 Mode:IX Flags: 0x2
06/30/2010 16:29:52,spid4s,Unknown,PAGE: 8:1:5293 CleanCnt:2 Mode:IX Flags: 0x2
How can I determine what this resource is, based on this PAGE information I am getting? Thanks in advance for your help!
it looks like the lock is being done at a page level. Check out http://msdn.microsoft.com/en-us/library/aa937573(SQL.80).aspx > Using Trace Flag 1204 > Terms in a Trace Flag 1204 Report > PAG
PAG
Identifies the page resource on which
a lock is held or requested.
PAG is represented in Trace Flag 1204
as PAG: db_id:file_id:page_no; for
example, PAG: 7:1:168.
Edit
Use DBCC PAGE (http://support.microsoft.com/kb/83065 or http://www.sqlmonster.com/Uwe/Forum.aspx/sql-server/26555/Determining-table-for-a-particular-File-id-Page-No) to get the object id from the page information,
then use OBJECT_NAME (http://msdn.microsoft.com/en-us/library/ms186301.aspx) or query sys.objects to get the resource

Windows Service Fails on Launch

I'm trying to write a windows service. It installs fine, but fails when I run it with the following exception. I've searched for the string "MyNewProgramService", but I can't find any conversions that would throw this error. I've also added try/catch blocks to a bunch of code with custom exception handling without finding where this exception is occuring. I'm thinking it's somewhere in the auto-generated configuartion/setup code. Any ideas?
Event Type: Error
Event Source: MyNewProgram Event
Category: None Event
ID: 0
Date: 4/15/2010
Time: 12:48:34 PM
User: N/A
Computer: 20F7KF1
Description: Service cannot be started. System.InvalidCastException:
Conversion from string "MyNewProgramService" to type 'Integer' is not valid. --->
System.FormatException: Input string was not in a correct format.
at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value,
NumberFormatInfo NumberFormat)
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
--- End of inner exception stack trace ---
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
at TaskManagerFailureHandlerService.MyNewProgramService.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
it falls in method MyNewProgramService.OnStart, there Conversions.ToInteger is called somewhere. Just search for it in method. Then check parameter. It might come from config or something, thats why you don't see string in text.
Check your configuration file.
You might also check the account the service is running as. Just as a test go to the login tab in the services list and have it login under your own account. If the problem vanishes it's a permissions problem.