Using a [file] datasource with WordDocument.MailMerge - vb.net

I get sent a log file each time this error happens, so it is definitely happening, I just haven't been able to find out how to reproduce it, or why its occurring.
I merge a Word document with a .dat file (through vb.net), my code that does the merge is simple:
document.WordDocument.MailMerge.OpenDataSource(document.MergeFilePath, wdOpenFormatText, , , False)
document.MergeFilePath points to a local physical .dat file that contains a datasource for the document to use.
On certain clients, this (intermittently) causes an error, some errors are different, but most are Exception: Word was unable to open the data source.
I have tried checking the following properties, when the document is merging, to ensure that they are correctly set / in the correct state before attempting to set the datasource:
Application.PrintPreview | Changed the ActiveWindow.View.Type | (from wdReadingView) | Options.AllowReadingMode.
Again, on my side this is all working perfectly fine and I haven't been able to get any errors - although I know they are occurring.
My log file has this in it:
Office version: Office2013
Word ViewType: wdNormalView
Word PrintPreview: False
Word AllowReadingMode: False
Exception details:
Stack Trace: at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn) at [PROJECT PATH].MergeDocument(Document& [document Object]) in [PROJECT Path]\FILENAME.vb:line 695
Things to note:
I've noticed it seems to only be on Office2013 (used to be all versions), but
seems the above changes fixed 2016).
I think it has to do with a document (or multiple documents) being
in a readMode state at some point
Something must be happening where it 'locks' certain properties and hence,
we are unable to update the datasource on the document.
Any help or a nudge in the right direction would be greatly appreciated.

Related

Why Automated Data Driven test cases using Tosca throwing -- No suitable value found for command 'XL'

I am trying to automate Salesforce instance using Tosca ,and i used "Automated Data Driven test cases" which is simply Recording of Test cases option using the Tosca tool ,after successful recording when i tried to execute the test case by "Run in scrapbook " option ,i see error as
No suitable value found for command 'XL'
Strange because i see values got populated in Tosca Test engine of excel generated as a result of recording
here
Here is detailed error log from Tosca
Tricentis.Automation.AutomationInstructions.TestActions.InvalidActionException: No suitable value found for command 'XL' ---> System.InvalidOperationException: No suitable value found for command 'XL'
at Tricentis.Automation.AutomationInstructions.Dynamic.Values.ValueFactory.CreateValues(IParsed parsed, DataType dataType)
at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Tricentis.Automation.AutomationInstructions.Dynamic.Values.ValueFactory.CreateValue(IEnumerable`1 parsedItems, DataType dataType)
at Tricentis.Automation.AutomationInstructions.Dynamic.ExpressionParser.ParseExpression(String expression, IEnumerable`1 tokenDefinitions, DataType dataType)
at Tricentis.Automation.AutomationInstructions.Dynamic.ExpressionParser.GetAsValues[T](String expression, TokenDefinitionSet tokenDefinitionSet, DataType dataType)
at Tricentis.Automation.AutomationInstructions.TestActions.AutomationObjectTestAction.get_Values()
at Tricentis.Automation.AutomationInstructions.TestActions.AutomationObjectTextBoxTestAction.get_Values()
at Tricentis.Automation.AutomationInstructions.TestActions.AutomationObjectTestAction.CreateSubTestActions()
at Tricentis.Automation.AutomationInstructions.TestActions.TestAction.get_InnerActions()
--- End of inner exception stack trace ---
at Tricentis.Automation.AutomationInstructions.TestActions.TestAction.get_InnerActions()
at Tricentis.Automation.AutomationInstructions.TestActions.TestAction.get_Actions()
at Tricentis.Automation.AutomationInstructions.TestActions.TestAction.<>c.<get_ExecutableChildren>b__32_1(ITestAction testAction)
at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Tricentis.Automation.AutomationInstructions.TestActions.TestAction.get_ExecutableChildren()
at Tricentis.Automation.AutomationInstructions.TestActions.TestAction.get_ConstrainingChildren()
at Tricentis.Automation.AutomationInstructions.TestActions.AutomationObjectSearchQuery.get_TestActionConstraints()
at Tricentis.Automation.Engines.Representations.Controllers.RepresentationController.get_ConstrainingChildTestActions()
at Tricentis.Automation.Engines.Representations.Controllers.RepresentationController.ConstrainBySubItems(IEnumerable`1 representations)
at Tricentis.Automation.Engines.Representations.Controllers.RepresentationController.ConstrainInternal(IEnumerable`1 representations, IModuleAttributeXParameters parameters)
at Tricentis.Automation.Engines.Representations.Controllers.RepresentationController.Constrain(IEnumerable`1 representations)
at Tricentis.Automation.Engines.Representations.Controllers.RepresentationController.SearchRepresentations(IAdapterController adapterController)
at Tricentis.Automation.Engines.Representations.Controllers.RootRepresentationController.SearchRepresentation()
at Tricentis.Automation.Engines.Representations.Controllers.RepresentationController.Search()
at ᜁ.ᜀ(IRepresentationController A_0)
at ᜁ.ᜁ(IRepresentationController A_0, IRepresentation& A_1)
at ᜂ.ᜀ(IRepresentationController A_0, IRepresentation& A_1)
at ᜁ.ᜀ()
Even I got the same error message. but now solved. I tried as below:
Converted test case to template and added the Test Sheet attributes to Template by drag n drop in respective locations. If you try to run the test steps at this point then you will get this error message "No Suitable Value found for command 'XL'",
This can be avoided by "Create Template Instance" from the menu or Instantiate icon from the icon from the tool bar and then run the instantiated item in Scratch Book. It should work without any error message. I used multiple user cased and all of them worked.
Note: other observation: make sure you do not delete the Values in the cells using right click and cross mark. just get in to cell and then remove.
You get this "No Suitable Value found for command 'XL'" when you try to run testcase from a template and not the template instance!!

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.

Catastrophic failure followed by MAPI_E_INTERFACE_NOT_SUPPORTED when trying to AddPstStore

I am trying to add pst store from outlook addin using Redemption with the code:
RdoSession = Redemption.RedemptionLoader.new_RDOSession();
RdoSession.MAPIOBJECT = (AddinModule.CurrentInstance as AddinModule).OutlookApp.Session.MAPIOBJECT;
string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + #"\Microsoft\Outlook\mystore.pst";
RDOStores stores = RdoSession.Stores;
RDOStore store = stores.AddPSTStore(path, Outlook.OlStoreType.olStoreDefault, "test");
Line stores.AddPstStore throws System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure and it creates mystore.pst in correct location with the size of 265 KBs. New store/data file is not displayed in outlook and it does not apear in RdoSession.Stores on next execution. So my program tries to create it again (since it didint found it) and then same line crashes with:
System.InvalidCastException: Error in IMsgServiceAdmin::AdminProviders: MAPI_E_INTERFACE_NOT_SUPPORTED
Using office PIAs code works without any problems:
https://msdn.microsoft.com/en-us/library/office/bb612380.aspx
I would keep redemption code since there is much more logic around it. I just moved these 5 lines to the begining of function to isolate the problem.
MAPI has a few marshaling bugs in the profile management interfaces (such as IMsgServiceAdmin).
Try to replace setting the RDOSession.MAPIOBJECT property with calling RDOSession.Logon.
Is you code running in a Outlook addin or a standalone app?

Active Directory related AppDomainUnloadedException in MVC4

I have an ASP.NET MVC application. It's run on a domain and we determine the user by calling UserPrincipal.Current. This works beautifully, most of the time. Every once in a while (maybe 1 out of 5 times), and only right after I publish my app to IIS, it will throw an AppDomainUnloadedException.
The specific line of my code causing the exception is:
if (UserPrincipal.Current.SamAccountName != null &&
_currentUserId != UserPrincipal.Current.SamAccountName) ...
The remainder of the call stack is:
mscorlib.dll!System.StubHelpers.StubHelpers.GetCOMHRExceptionObject(int hr, System.IntPtr pCPCMD, object pThis) + 0xe bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.LoadDomainInfo() + 0x358 bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.DnsDomainName.get() + 0x5e bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.GetAsPrincipal(object storeObject, object discriminant = {Name = "UserPrincipal" FullName = "System.DirectoryServices.AccountManagement.UserPrincipal"}) + 0x17a bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRefHelper(System.Type principalType, string urnScheme, string urnValue, System.DateTime referenceDate, bool useSidHistory) + 0x576 bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRef(System.Type principalType, string urnScheme, string urnValue, System.DateTime referenceDate) + 0x35 bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(System.DirectoryServices.AccountManagement.PrincipalContext context, System.Type principalType, System.DirectoryServices.AccountManagement.IdentityType? identityType, string identityValue, System.DateTime refDate) + 0x9e bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(System.DirectoryServices.AccountManagement.PrincipalContext context, System.Type principalType, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue) + 0x5b bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(System.DirectoryServices.AccountManagement.PrincipalContext context, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue) + 0x1e bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.UserPrincipal.Current.get() + 0xc1 bytes
After a great deal of digging around, and due to the random nature of the exception, I concluded the problem was probably related to this:
http://support.microsoft.com/kb/2683913
So I installed the hotfix and as expected, the problem went away. That was Tuesday. This morning, the exception started up again. I verified that the hotifx is in fact installed. I turned on module load messages and got:
'w3wp.exe': Loaded 'C:\Windows\SysWOW64\activeds.dll', Cannot find or open the PDB file.
So I verified that that .dll is in fact the one from the hotfix and it is (size and version #s match).
At the same time I get this exception, I get this event in the event log:
A process serving application pool 'WebSitePool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '7404'. The data field contains the error number.
The only data in the error is: 0x8007006D which I believe simply means there was a fatal communication error which the error already said...
Humorously, when the exception dialog pops up it states, "If there is a handler for this exception, the program may be safely continued." Which is true if your app has no need for UserPrincipal.Current, but calling it again after this exception causes the exception to rethrow, so I'd question their "safely continued" assertion there.
Now, if I rerun the app, I won't get a problem. I have yet to have this happen any time, other than right after publishing. Because of our setup and relations to other projects, this app must be debugged under IIS, which means I have to publish it every time I make a code change which means I normally see this throughout the day (Tuesday afternoon and yesterday being the exceptions).
It seems curious to me that, from digging around, it appears this bug is frequently associated with ASP.NET MVC, but I don't believe I've seen it associated with WinForms or ASP.NET... I can't see how that would matter, but maybe there's a relationship there.
I suspect this is an MS bug. I can't imagine that there's any legitimate condition under which UserPrincipal.Current should cause an AppDomainUnloadedException, but I thought I'd take a shot here on Stackoverflow...