EzApi Issue with Excel Connection Manager - excel

EzApi is used to create SSIS package, package reads excel file through oledb connection manager(microsoft.ace.oledb.12.0) When i create EzExecSQLTask object after dataflow that reads the excel file,
i got the exception : object does not match the target type
After Debugging the EzApi code i found below line is generating the exception
host.Properties["TimeOut"].SetValue(host, value);
it seemed that when the property is set through reflection it doesn't find the target object.
Code works fine on widows xp machine , but on windows Server 2012 its causing the issue.
stack trace
at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at Microsoft.SqlServer.Dts.Runtime.ManagedHelper.ManagedPropertyHelper.SetPropertyValue(Object o, Int32 index, Object value)
at Microsoft.SqlServer.Dts.Runtime.DtsProperty.SetValue(Object o, Object value)
at Microsoft.SqlServer.SSIS.EzAPI.EzExecSqlTask.set_TimeOut(UInt32 value) in d:\ROI_ETL\ROi\ETL\Optime.ISS.ETL.EzApi\EzExecutables.cs:line 751
at Microsoft.SqlServer.SSIS.EzAPI.EzExecSqlTask.InitializeTask() in d:\ROI_ETL\ROi\ETL\Optime.ISS.ETL.EzApi\EzExecutables.cs:line 740
at Microsoft.SqlServer.SSIS.EzAPI.EzExecSqlTask..ctor(EzContainer parent) in d:\ROI_ETL\ROi\ETL\Optime.ISS.ETL.EzApi\EzExecutables.cs:line 732
at Microsoft.SqlServer.SSIS.EzAPI.Common.ComponentWrapper.CreateSQLTaskWithExpression(EzContainer p, String name, String sql, EzConnectionManager cm) in d:\ROI_ETL\ROi\ETL\Optime.ISS.ETL.EzApi\Common\ComponentWrapper.cs:line 55
at Microsoft.SqlServer.SSIS.EzAPI.SSI_Wrapper.SSIPackage.LogMessage(String stepID, String stepName, String userID, String statusID, String message, String sqlTaskName, EzExecutable attachToComp, EzConnectionManager cm) in d:\ROI_ETL\ROi\ETL\Optime.ISS.ETL.EzApi\SSI Wrapper\SSIPackage.cs:line 723
at Microsoft.SqlServer.SSIS.EzAPI.SSI_Wrapper.SSIPackage.CreatePackage(Int64 userID, Nullable`1 sourceID, Int64 taskID, Boolean isSystemTask, StepDTO step, List`1 execStatus) in d:\ROI_ETL\ROi\ETL\Optime.ISS.ETL.EzApi\SSI Wrapper\SSIPackage.cs:line 178
at Optime.ISS.ETL.WebAPI.SSISPackageController.ExecuteTask(TaskDTO task) in d:\ROI_ETL\ROi\ETL\Optime.ISS.ETL.WebAPI\SSISPackageController.cs:line 77
More Information
Issue occured only on windows server 2012 when microsoft.ace.oledb.12.0 is used to connect to excel file. Same code works fine in window xp with microsoft.ace.oledb.12.0 32 bit drivers
please help.... we can move any further.
please suggest right forum.

Related

Adding Vendor lookup to custom field

I added a custom field for vendorid on the SO Line. (Yes, I know there is one there, but we are building some new logic). I've added the integer field and it appears on the grid fine. I'm trying to get a lookup of vendors. I started with this
Where<AP.Vendor.type, NotEqual<BAccountType.employeeType>>>))]
and then tried
Where<BAccountR.type, Equal<BAccountType.companyType>,
Or<AP.Vendor.type, NotEqual<BAccountType.employeeType>>>>),
Visibility = PXUIVisibility.SelectorVisible, CacheGlobal = true, Filterable = true)]
It got me a lookup on new records, but then when I save and try to open any sales order, I get an error that says "Error: An error occurred during the processing of the field InventoryID: Specified cast is not valid.." which makes no sense to me. But if I remove the above it works, so seems like that must be the issue.
Stack Trace as requested:
Error: Error: An error occurred during processing of the field InventoryID: Specified cast is not valid..
Raised At: 2/24/2020 6:47:58 PM Screen: SO.30.10.00
Details:
2/24/2020 6:47:58 PM Error:
Error: An error occurred during processing of the field InventoryID: Specified cast is not valid..
System.InvalidCastException: Specified cast is not valid.
at System.Data.SqlClient.SqlBuffer.get_Int32()
at PX.Data.PXDataRecord.GetInt32(Int32 i)
at PX.Data.PXDBIntAttribute.RowSelecting(PXCache sender, PXRowSelectingEventArgs e)
at PX.Data.PXCache.OnRowSelecting(Object item, PXDataRecord record, Int32& position, Boolean isReadOnly)
at PX.Data.PXCache.OnRowSelecting(Object item, PXDataRecord record, Int32& position, Boolean isReadOnly)
at PX.Data.PXCache`1.Select(PXDataRecord record, Int32& position, Boolean isReadOnly, Boolean& wasUpdated)
at PX.Data.PXView.GetResult(Object[] parameters, PXFilterRow[] filters, Boolean reverseOrder, Int32 topCount, PXSearchColumn[] sorts, Boolean& overrideSort, Boolean& extFilter)
at PX.Data.PXView.Select(Object[] currents, Object[] parameters, Object[] searches, String[] sortcolumns, Boolean[] descendings, PXFilterRow[] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows)
at PX.Objects.SO.SOOrderEntry.transactions()
at _CustomMethod(Object , Object[] )
at PX.Data.PXView.InvokeDelegate(Object[] parameters)
at PX.Data.PXView.Select(Object[] currents, Object[] parameters, Object[] searches, String[] sortcolumns, Boolean[] descendings, PXFilterRow[] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows)
at PX.Data.PXGraph.ExecuteSelect(String viewName, Object[] currents, Object[] parameters, Object[] searches, String[] sortcolumns, Boolean[] descendings, PXFilterRow[] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows)
Anyone have any thoughts?
TL;DR;
Remove PXDBInt attribute from the field.
The issue here is not with Where condition but with attributes definition for the field.
[PXDBInt]
[PXUIField(DisplayName="Vendor ID")]
[AP.Vendor(typeof(Search<BAccountR.bAccountID, Where<AP.Vendor.type,
NotEqual<BAccountType.employeeType>>>))]
Actually, here you have DBField attribute twice. You have PXDBIntAttribute and Vendor attribute that contains PXDBIntAttribute inside.
Because of that the framework has the wrong fields to db columns mapping resulting in that strange error.
If you use Visual studio, I recommend you to try Acuminator extension https://marketplace.visualstudio.com/items?itemName=Acumatica.Acuminator
It highlights that type of errors
Too long for a comment, but more of a suggestion than an "answer". Try building your own PXSelector. I have a custom DAC that needs to store two vendors, and I had to abandon the AP.Vendor attribute for a custom PXSelector for mine to work. This is one of mine. In my case, I need to be able to see which one is defined as the Preferred Vendor for the warehouse, and I only want to see vendors associated with my InventoryID. SSINItemBranch is a custom DAC that is also available in the scope of this DAC's usage. The point is, use this as an example if you need one to try creating your own from scratch. If this isn't how you want to accomplish the task, at least you might isolate if the problem is a use case of the AP.Vendor attribute or something else.
[PXSelector(
typeof(Search2<
Vendor.bAccountID,
InnerJoin<POVendorInventory,
On<POVendorInventory.vendorID, Equal<Vendor.bAccountID>,
And<POVendorInventory.inventoryID, Equal<Current<SSINItemBranch.inventoryID>>>>,
LeftJoin<INItemSite, On<INItemSite.inventoryID, Equal<POVendorInventory.inventoryID>,
And<INItemSite.preferredVendorID, Equal<POVendorInventory.vendorID>,
And<INItemSite.preferredVendorLocationID, Equal<POVendorInventory.vendorLocationID>,
And<INItemSite.preferredVendorOverride, Equal<True>>>>>>>,
Where<Vendor.type, Equal<BAccountType.vendorType>>>),
typeof(Vendor.acctCD),
typeof(Vendor.acctName),
typeof(POVendorInventory.vendorLocationID),
typeof(INItemSite.preferredVendorOverride),
typeof(POVendorInventory.vendorInventoryID),
typeof(POVendorInventory.vLeadTime),
SubstituteKey = typeof(Vendor.acctCD),
DescriptionField = typeof(Vendor.acctName),
Filterable = true
)]

How to get file stream from the sharepoint file url in dynamic crm plugin?

I have requirement to get file stream of share point file, for the that I have share point file URL.
https://mysite.sharepoint.com/sites/documents/contact/test/Beat01_07262017.pdf
I’m trying to connect to SharePoint Online (using CSOM) from within a plugin in CRM Online . For that to work, I merged the SharePoint Client and Client.Runtime DLL’s with ilmerge.exe into my plugin DLL. But as soon as the following code:
ClientContext clientContext = new ClientContext(server);
clientContext.Credentials = new SharePointOnlineCredentials(UserId, Password); // This line throws an below exception:
Request for the permission of type
‘System.Security.Permissions.RegistryPermission, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′
failed.
Is there any way to make it working?
I have checked with SharePoint Integration from CRM Online Workflow/Plugin but not able to get it working
and getting error as below
Exception: Exception has been thrown by the target of an invocation.
Stack Trace at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.DynamicInvoke(Delegate project,
Object[] args)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateExpressionToConditionValue(Expression
exp, ParameterExpression[] parameters)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhereCondition(BinaryExpression
be, FilterExpressionWrapper parentFilter, Func 2 getFilter, Func 2
getLinkLookup, Boolean negate)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhere(String
parameterName, BinaryExpression be, FilterExpressionWrapper
parentFilter, Func 2 getFilter, List 1 linkLookups, Boolean
negate)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhereBoolean(String
parameterName, Expression exp, FilterExpressionWrapper parentFilter,
Func 2 getFilter, List 1 linkLookups, BinaryExpression parent, Boolean
negate)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhere(QueryExpression
qe, String parameterName, Expression exp, List 1 linkLookups)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetQueryExpression(Expression
expression, Boolean& throwIfSequenceIsEmpty, Boolean&
throwIfSequenceNotSingle, Projection& projection,
NavigationSource& source, List 1& linkLookups)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](Expression
expression)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression
expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable 1
source)
at CRMPluginProject1._365Immo.Laurus.SharePoint.DocumentLocationHelper.GetDocumentLocationPath(SharePointDocumentLocation
parentLocation)
at CRMPluginProject1._365Immo.Laurus.SharePoint.DocumentLocationHelper.CreateDocumentLocation(Entity
site, String documentLibraryName, EntityReference
regardingRecord)
at CRMPluginProject1._365Immo.Laurus.Plugins.GetSharePointFile.Execute(IServiceProvider
serviceProvider)
Inner Exception :
The demand failed due to the code access security information captured during the creation of an anonymously hosted
dynamic method. In order for this operation to succeed, ensure that
the demand would have succeeded at the time the method was created.
See http://go.microsoft.com/fwlink/?LinkId=288746 for more
information.
Stack Trace : at lambda_method(Closure )
The SharePoint client library apparently needs access to the Windows registry. This is not allowed in sandboxed CRM plugins.
In sandboxed plugins code is only allowed to access resources on the web using the http or https protocol. (IP addresses are not allowed either.)

The "GenerateResource" task failed unexpectedly

Windows 10, VS2013 professional
Window phone silverlight 8.1 application.
The error is:
The "GenerateResource" task failed unexpectedly.
System.InvalidOperationException: Item named 'xamls/simplelogin.xaml' of type 'System.IO.UnmanagedMemoryStream' cannot be added to the resource file because it is not serializable.
at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(ReaderInfo reader, IResourceWriter writer)
at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(ReaderInfo reader, String filename)
at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFileOrDir)
at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, List`1 inputs, List`1 satelliteInputs, List`1 outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass, Boolean extractingResWFiles, String resWOutputDirectory)
at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, List`1 inputs, List`1 satelliteInputs, List`1 outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass, Boolean extractingResWFiles, String resWOutputDirectory)
at Microsoft.Build.Tasks.GenerateResource.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() CarManagerWpApp
When i remove the "Microsoft.Sharepoint.Client.Phone.Auth.UI" reference, everything is allright. Unfortunately, this dll is crutial for me. I have seen a lot of 'The "GenerateResource" task failed unexpectedly' errors on net, none of solutions helped me.
Anyone has any idea? Thank you

ssis script task corrupts excel 2010 file

I am trying to format an Excel 2010 doc and the file creates fine and the data is there, but when the script task goes to format the file it gets corrupted. I have also noticed that it will only read the first of 2 worksheets. Here is the code:
Dim lintLastRow As Integer
Dim lstrLastCol, lstrHeader As String
Dim mobjWorkbook As Workbook
Dim mappExcel As New Microsoft.Office.Interop.Excel.Application
Dim lobjWorksheet As Worksheet
Dim emptyBytes(0) As Byte
Dim oldCI As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
Try
mappExcel.Visible = False
mappExcel.DisplayAlerts = False
mappExcel.AskToUpdateLinks = False
mappExcel.AlertBeforeOverwriting = False
mobjWorkbook = mappExcel.Workbooks.Open(Dts.Variables("FilePath").Value + Dts.Variables("FileName").Value)
mobjWorkbook.RefreshAll()
Dts.Log("worksheet count: " & mobjWorkbook.Sheets.Count, 0, emptyBytes)
For Each lobjWorksheet In mobjWorkbook.Sheets
If lobjWorksheet.Name = "Compare" Then
lstrLastCol = "T"
lstrHeader = "- Compare Results"
Else
lstrLastCol = "H"
lstrHeader = "- Trans UnMatch"
End If
'Dts.Log("Set worksheet: " & lintCount, 0, emptyBytes)
'lobjWorksheet = mobjWorkbook.Sheets.Item(lintCount)
Dts.Log("worksheet select", 0, emptyBytes)
lobjWorksheet.Select()
lobjWorksheet.Range("A1").Select()
If lobjWorksheet.Cells(2, 1).value = Nothing Then
lintLastRow = 4
Else
lobjWorksheet.Application.Cells.End(XlDirection.xlDown).Select()
lintLastRow = lobjWorksheet.Application.ActiveCell.Row + 2
End If
Dts.Log("last row: " & lintLastRow, 0, emptyBytes)
lobjWorksheet.Rows(1).Insert(XlInsertShiftDirection.xlShiftDown, False)
lobjWorksheet.Rows(1).Insert(XlInsertShiftDirection.xlShiftDown, False)
lobjWorksheet.Cells(1, 1).value = "PAM - GL Portfolio Level " + lstrHeader + " for " + Today
lobjWorksheet.Range("A1", lstrLastCol + "1").Merge()
lobjWorksheet.Range("A1").RowHeight = 27
lobjWorksheet.Range("A1", lstrLastCol + "3").Font.Bold = True
lobjWorksheet.Range("C4", lstrLastCol & lintLastRow).NumberFormat = "0.00" ' = FormatNumber("#####.00").
lobjWorksheet.Range("A3", lstrLastCol & lintLastRow).EntireColumn.AutoFit()
lobjWorksheet.Range("A1", lstrLastCol & lintLastRow).Font.Name = "Arial"
lobjWorksheet.Range("A1").Select()
Dts.Log("Complete Update", 0, emptyBytes)
Next
mobjWorkbook.Sheets("Compare").Select()
Dts.TaskResult = ScriptResults.Success
Catch ex As Exception
Dts.Events.FireError(0, "Format Excel Failed: ", _
ex.Message & ControlChars.CrLf & ex.StackTrace, _
String.Empty, 0)
Dts.TaskResult = ScriptResults.Failure
Finally
System.Threading.Thread.CurrentThread.CurrentCulture = oldCI
mobjWorkbook.Save()
mobjWorkbook.Close()
ReleaseCom(lobjWorksheet)
ReleaseCom(mobjWorkbook)
mappExcel.Quit()
ReleaseCom(mappExcel)
GC.Collect()
GC.WaitForPendingFinalizers()
End Try
This works fine on my machine and a pilot environment. When it goes to production things go downhill quick. Any thoughts on what I am missing would be great.
Thanks
So the original issue I believe was caused by the Excel converter not being installed on the server. Once that was install, I started to get the following error:
OnError,PGIDSMSQL045,PRINCIPALUSA\TWSPGIAC,Formate Excel,{610A1615-E16E-4B62-8A93-F692A478FCF9},{EF8F3734-6467-423C-A9D3-BF2463EEFD44},04/18/2013 11:52:09 AM,04/18/2013 11:52:09 AM,0,0x,The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)) at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
at ST_0391e3bc80224a34819c14be208559c5.vbproj.ScriptMain.Main()
OnError,PGIDSMSQL045,PRINCIPALUSA\TWSPGIAC,PAM-GLPortLvlRecon,{008D2838-612E-4DBB-AEE7-65145ED0BAAC},{EF8F3734-6467-423C-A9D3-BF2463EEFD44},04/18/2013 11:52:09 AM,04/18/2013 11:52:09 AM,0,0x,The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
at ST_0391e3bc80224a34819c14be208559c5.vbproj.ScriptMain.Main()
OnError,PGIDSMSQL045,PRINCIPALUSA\TWSPGIAC,Formate Excel,{610A1615-E16E-4B62-8A93-F692A478FCF9},{EF8F3734-6467-423C-A9D3-BF2463EEFD44},04/18/2013 11:52:09 AM,04/18/2013 11:52:09 AM,8,0x,The script returned a failure result.
OnError,PGIDSMSQL045,PRINCIPALUSA\TWSPGIAC,PAM-GLPortLvlRecon,{008D2838-612E-4DBB-AEE7-65145ED0BAAC},{EF8F3734-6467-423C-A9D3-BF2463EEFD44},04/18/2013 11:52:09 AM,04/18/2013 11:52:09 AM,8,0x,The script returned a failure result.
OnError,PGIDSMSQL045,PRINCIPALUSA\TWSPGIAC,Formate Excel,{610A1615-E16E-4B62-8A93-F692A478FCF9},{EF8F3734-6467-423C-A9D3-BF2463EEFD44},04/18/2013 11:52:09 AM,04/18/2013 11:52:09 AM,1,0x,System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at ST_0391e3bc80224a34819c14be208559c5.vbproj.ScriptMain.Main()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
OnError,PGIDSMSQL045,PRINCIPALUSA\TWSPGIAC,PAM-GLPortLvlRecon,{008D2838-612E-4DBB-AEE7-65145ED0BAAC},{EF8F3734-6467-423C-A9D3-BF2463EEFD44},04/18/2013 11:52:09 AM,04/18/2013 11:52:09 AM,1,0x,System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at ST_0391e3bc80224a34819c14be208559c5.vbproj.ScriptMain.Main()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
This has been more fun then I ever wanted...but a good challange.
I have check the variables and they have the correct information. The user has full access to the output directory because it creates the file in earlier steps. So I am not sure what I am missing. Note: This whole process works when it was formatting an .xls file so I am not sure what is going on with .xlsx.
thanks
The converter was installed and must have needed a reboot because the server was rebooted this weekend and everything seems to be working. So I think we are good now.

Linq to nhibernate - find values starting with number

I'm using Linq to NHibernate and I have a need to find all records with a column ("BusinessName") that start with a number.
My first thought was something like this:
var numbers = Enumerable.Range(0, 10).Select(x => x.ToString()).ToList();
query = query.Where(x=>numbers.Contains(x.BusinessName.Substring(0,1)));
But I'm getting the exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetEntityName(ICriteria subcriteria, String propertyName)
at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetType(ICriteria subcriteria, String propertyName)
at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetTypeUsingProjection(ICriteria subcriteria, String propertyName)
at NHibernate.Criterion.InExpression.AssertPropertyIsNotCollection(ICriteriaQuery criteriaQuery, ICriteria criteria)
at NHibernate.Criterion.InExpression.ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary`2 enabledFilters)
at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetWhereCondition(IDictionary`2 enabledFilters)
at NHibernate.Loader.Criteria.CriteriaJoinWalker..ctor(IOuterJoinLoadable persister, CriteriaQueryTranslator translator, ISessionFactoryImplementor factory, ICriteria criteria, String rootEntityName, IDictionary`2 enabledFilters)
at NHibernate.Loader.Criteria.CriteriaLoader..ctor(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria, String rootEntityName, IDictionary`2 enabledFilters)
at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results)
at NHibernate.Impl.CriteriaImpl.List(IList results)
at NHibernate.Impl.CriteriaImpl.List()
at NHibernate.Impl.CriteriaImpl.UniqueResult()
at NHibernate.Linq.Visitors.ImmediateResultsVisitor`1.HandleAggregateCall(MethodCallExpression call)
at NHibernate.Linq.Visitors.ImmediateResultsVisitor`1.VisitMethodCall(MethodCallExpression call)
at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp)
at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp)
at NHibernate.Linq.Visitors.ImmediateResultsVisitor`1.GetResults(MethodCallExpression expr)
at NHibernate.Linq.Visitors.RootVisitor.HandleImmediateResultsCall(MethodCallExpression call)
at NHibernate.Linq.Visitors.RootVisitor.VisitMethodCall(MethodCallExpression expr)
at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp)
at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp)
at NHibernate.Linq.Visitors.NHibernateQueryTranslator.TranslateInternal(Expression expression)
at NHibernate.Linq.Visitors.NHibernateQueryTranslator.Translate(Expression expression, QueryOptions queryOptions)
at NHibernate.Linq.NHibernateQueryProvider.TranslateExpression(Expression expression)
at NHibernate.Linq.NHibernateQueryProvider.Execute(Expression expression)
at NHibernate.Linq.QueryProvider.System.Linq.IQueryProvider.Execute[T](Expression expression)
at System.Linq.Queryable.Count[TSource](IQueryable`1 source)
at SBON.ApiWrapper.SearchBusinesses(Nullable`1 id, String filter, String type, String letter, Nullable`1 start, Nullable`1 count) in D:\Data\Projects\Active\Clients\OfficeDepotSBON\src\SBON\ApiWrapper.cs:line 313
at SBONWeb.Controllers.MobileController.SearchBusinesses(String letter, String filter, Nullable`1 start, Nullable`1 count) in D:\Data\Projects\Active\Clients\OfficeDepotSBON\src\SBONWeb\Controllers\MobileController.cs:line 38
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
I don't really understand the exception, but I assume it has something to do with my use of substring to try match the first character against a list of numbers, since I can do the following without issue:
var numbers = Enumerable.Range(0, 10).Select(x => x.ToString()).ToList();
query = query.Where(x=>numbers.Contains(x.BusinessName));
How would you do this? Optimally I'm looking for a LINQ query that will work, but I might be able to resort to using an NHibernate named query (stored proc) if that's the only way to do this.
Bump for the Monday crowd.
This should do the trick
query = query.Where(x => char.IsNumber(x.BusinessName[0]));

Resources