I am trying to enumerate the different mail items in an Outlook folder.
Some of the mail items are ReportItems ... I can tell this because their Class = 46. However, when I try to cast the __ComObject to a ReportItem using ((Outlook.ReportItem)item) I get this exception:
AutoResolvedWinner {System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: The operation failed.
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Dynamic.IDispatchComObject.GetMembers(IEnumerable`1 names)} System.Reflection.TargetInvocationException
If it helps, the MessageClass property of the object is "REPORT.IPM.Note.NDR"
Help would be appreciated.
Related
I'm getting this error when trying to publish any item from Sitecore to the web. Was working fine the other day, not sure what I did to crash this.
Job started: Publish to 'web'|#Exception:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.InvalidOperationException:
Root item is not defined at
Sitecore.Diagnostics.Assert.IsNotNull(Object value, String message)
at Sitecore.Search.Crawlers.DatabaseCrawler.Initialize(Index index)
at Sitecore.Search.Index.AddCrawler(ICrawler crawler) --- End of
inner exception 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.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[]
parameters) at
Sitecore.Configuration.Factory.AssignProperties(Object obj, Object[]
properties) at
Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode,
String[] parameters, Object obj, Boolean assert, Boolean deferred,
IFactoryHelper helper) at
Sitecore.Configuration.Factory.CreateObject(XmlNode configNode,
String[] parameters, Boolean assert, IFactoryHelper helper) at
Sitecore.Configuration.Factory.GetInnerObject(XmlNode paramNode,
String[] parameters, Boolean assert) at
Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode,
String[] parameters, Object obj, Boolean assert, Boolean deferred,
IFactoryHelper helper) at
Sitecore.Configuration.Factory.CreateObject(XmlNode configNode,
String[] parameters, Boolean assert, IFactoryHelper helper) at
Sitecore.Configuration.Factory.CreateObject(String configPath,
String[] parameters, Boolean assert) at
Sitecore.Search.SearchManager.get_SearchConfiguration() at
Sitecore.Data.Managers.IndexingManager.UpdateIndexAsync(Database
database) at Sitecore.MainUtil.RaiseEvent[T](EventHandler1
subscribers, Object sender, T eventArgs) at
Sitecore.Data.Engines.HistoryEngine.RegisterItemSaved(Item item,
ItemChanges changes) at System.EventHandler1.Invoke(Object sender,
TEventArgs e) at
Sitecore.Data.Engines.EngineCommand2.RaiseEvent[TArgs](EventHandler1
handlers, Func2 argsCreator) at
Sitecore.Data.Engines.EngineCommand2.Execute() at
Sitecore.Data.Engines.DataEngine.SaveItem(Item item) at
Sitecore.Data.Managers.ItemProvider.SaveItem(Item item) at
Sitecore.Data.Items.ItemEditing.AcceptChanges(Boolean
updateStatistics, Boolean silent) at
Sitecore.Data.Items.EditContext.Dispose() at
Sitecore.Publishing.PublishHelper.CopyToTarget(Item sourceVersion)
at Sitecore.Publishing.PublishHelper.PublishVersionToTarget(Item
sourceVersion, Item targetItem, Boolean targetCreated) at
Sitecore.Publishing.Pipelines.PublishItem.PerformAction.ExecuteAction(PublishItemContext
context) at
Sitecore.Publishing.Pipelines.PublishItem.PerformAction.Process(PublishItemContext
context) at (Object , Object[] ) at
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at
Sitecore.Publishing.Pipelines.PublishItem.PublishItemPipeline.Run(PublishItemContext
context) at
Sitecore.Publishing.Pipelines.Publish.ProcessQueue.ProcessEntries(IEnumerable1
entries, PublishContext context) at
Sitecore.Publishing.Pipelines.Publish.ProcessQueue.ProcessEntries(IEnumerable1
entries, PublishContext context) at
Sitecore.Publishing.Pipelines.Publish.ProcessQueue.ProcessEntries(IEnumerable1
entries, PublishContext context) at
Sitecore.Publishing.Pipelines.Publish.ProcessQueue.ProcessEntries(IEnumerable1
entries, PublishContext context) at
Sitecore.Publishing.Pipelines.Publish.ProcessQueue.Process(PublishContext
context) at (Object , Object[] ) at
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at
Sitecore.Publishing.Pipelines.Publish.PublishPipeline.Run(PublishContext
context) at Sitecore.Publishing.Publisher.PublishWithResult()
--- End of inner exception 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.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[]
parameters) at (Object , Object[] ) at
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at
Sitecore.Jobs.Job.ThreadEntry(Object state)
It looks like the index configuration is corrupted.
Go to /sitecore/admin/showconfig.aspx page and find:
<locations hint="list:AddCrawler">
Check every location under that node - they all should have <Root> tag with the proper location root specified.
You can check Sitecore logs. As per my finding it is occurred because I've specified wrong username/password in connectionstrings.config. Please make sure username and password is correct.
I'm having difficulties trying to figure this out. Any help is greatly appreciated. My restClient.Object gets a null exception. When I inspect the .Object of the restClient I get
Message: Exception has been thrown by the target of an invocation.
Inner Exception: Value cannot be null.Parameter name: source
Stack Trace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at Castle.DynamicProxy.ProxyGenerator.CreateClassProxyInstance(Type proxyType, List`1 proxyArguments, Type classToProxy, Object[] constructorArguments)
at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)
at Moq.Proxy.CastleProxyFactory.CreateProxy(Type mockType, ICallInterceptor interceptor, Type[] interfaces, Object[] arguments)
at Moq.Mock`1.<InitializeInstance>b__2()
at Moq.PexProtector.Invoke(Action action)
at Moq.Mock`1.InitializeInstance()
at Moq.Mock`1.OnGetObject()
at Moq.Mock.GetObject()
at Moq.Mock.get_Object()
at Moq.Mock`1.get_Object()
Btw, I'm referring to this line of code:
var client = new IncidentRestClient(**restClient.Object**);
Am I mocking the object incorrectly?
[Test]
public void Insert_Method_Throws_exception_if_response_StatusCode_is_not_Created()
{
//Arrange
var restClient = new Mock<RestClient>();
restClient.Setup(x => x.Execute<RootObject>(It.IsAny<IRestRequest>()))
.Returns(new RestResponse<RootObject>
{
StatusCode = HttpStatusCode.BadRequest
});
var client = new IncidentRestClient(restClient.Object);
Assert.Throws<Exception>(() => client.CreateNewIncident(insertIncidentRequest));
}
Uninstalling and reinstalling Moq did not work for me. Instead, setting the CallBase property on the Mock object to true did the trick:
var restClientMock = new Mock<RestClient> { CallBase = true };
Issue has been resolved. I had to uninstall and reinstall Moq with nuget.
I'm writing SSIS that scans a SQL table, create an object from each record values and need to move it next to other SSIS flow elements.
I created object type variable (MyObject) and script task.
In my script task I wrote the next code:
RequestObject reqObj = new RequestObject();
reqObj.building = Dts.Variables["reqObj_Building"].Value.ToString();
reqObj.ID = Convert.ToInt32(Dts.Variables["reqObj_DeviceID"].Value);
//...
Now I tried to write the next code in order to assin reqObj into myObject.
Dts.Variables["myObject"].Value = new RequestObject();
Dts.Variables["myObject"].Value = reqObj;
but those lines throws the next run time exception :
Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException: The element cannot be found in a collection. This error happens when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.
---> System.Runtime.InteropServices.COMException (0xC0010009): The element cannot be found in a collection. This error happens when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.
at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSVariables100.get_Item(Object Index)
at Microsoft.SqlServer.Dts.Runtime.Variables.get_Item(Object index)
--- End of inner exception stack trace ---
at Microsoft.SqlServer.Dts.Runtime.Variables.get_Item(Object index)
at ST_a3e0b574a8964ffb8af6f9fee31d5afd.csproj.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()
How can I assign custom object into SSIS Object type variable ?
It it possible?
Thanks
I don't have enough reputation to comment so I'm adding an answer instead. I did the below steps to try and replicate your problem:
Created a new script task
Created a new class in the namespace of that script
Created a variable of type Object and added to script task as Read/Write variable
Initialised the new class and assigned that value to the Object variable.
Below is my code which ran successfully. Can you please explain if there is any thing I am missing/understanding wrong?
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
namespace ST_8eab6a8fbc79431c8c9eb80339c09d1d.csproj
{
public class myclass
{
int a, b;
public myclass()
{
a = 0;
b = 0;
}
}
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
public void Main()
{
Dts.TaskResult = (int)ScriptResults.Success;
myclass m = new myclass();
Dts.Variables["myObject"].Value = m;
}
}
}
I have an application test framework developed in C# which stores the result in an Excel file after each step. When executed inside the solution everything works fine. But when I am integrating the solution with Fitnesse and calling the method, an error is thrown. I have added the stack trace from Fitness below.
The code segment is here:
public class ExcelReports : IReporter
{
private Excel.Application xlReport;
public ExcelReports()
{
xlReport = new Excel.Application();
Excel.Workbook xlWorkbook = xlReport.Workbooks.Add();
***xlWorkbook.SaveAs(ExecutionContext.RESULTFILE);***
}
}
The error is reported at xlWorkbook.SaveAs(ExecutionContext.RESULTFILE)
I am using the fit and fitsharp dlls for the .NET 4.0 release.
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.Runtime.InteropServices.COMException: Microsoft Excel cannot access the file
'C:\0452CB00'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open
workbook.
at Microsoft.Office.Interop.Excel._Workbook.SaveAs(Object Filename, Object
FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended,
Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution,
Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local)
at EF.UIAutomation.Commons.ExcelReports..ctor() in
C:\EF.Automation\EF.UIAutomation.PageLibrary\Libraries\EF.UIAutomation.Commons.Reports.cs:l ine 25
at EF.UIAutomation.Launcher.Program.Test() in
C:\EF.Automation\EF.Automation\Program.cs:line 26
--- End of inner exception stack trace ---
at fitSharp.Machine.Model.TypedValue.ThrowExceptionIfNotValid()
at fitSharp.Fit.Operators.CompareDefault.Compare(TypedValue actualValue, Tree`1
expected)
at fitSharp.Machine.Engine.ProcessorBase`2.<>c__DisplayClass3.
<>c__DisplayClass5.b__2(CompareOperator`1 o)
at fitSharp.Machine.Engine.Operators`2.Do[O](CanDoOperation`1 canDoOperation,
DoOperation`1 doOperation)
at fitSharp.Machine.Engine.ProcessorBase`2.
<>c__DisplayClass3.b__0(OperationLogging logging)
at fitSharp.Machine.Engine.ProcessorBase`2.DoLoggedOperation[R](String
startMessage, Func`2 operation)
at fitSharp.Machine.Engine.ProcessorBase`2.Compare(TypedValue instance, Tree`1
parameters)
at fitSharp.Fit.Operators.CheckDefault.Check(CellOperationValue actualValue,
Tree`1 expectedCell)
--- End of inner exception 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.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 fitSharp.Machine.Engine.MethodMember.TryInvoke(Object[] parameters)
at fitSharp.Machine.Engine.ReflectionMember.Invoke(Object[] parameters)
at fitSharp.Machine.Engine.ProcessorBase`2.Operate[O](Object[] parameters)
at fitSharp.Fit.Engine.CellProcessorExtension.Check(CellProcessor processor,
Object systemUnderTest, Tree`1 memberName, Tree`1 parameters, Tree`1 expectedCell)
at fitSharp.Fit.Service.CheckBinding.Do(Tree`1 cell)
at fitSharp.Fit.Service.Binding.Do(Tree`1 cell)
at fit.ColumnFixture.DoCell(Parse cell, Int32 column)
I am trying to use SSIS to open an Excel file and refresh the data before importing the data into SQL Server. My dtsx package is failing on the line of code that tries to open the Excel file.
The code is straightforward and taken from here.
This is the code I am using:
public void Main()
{
// TODO: Add your code here
Dts.TaskResult = (int)ScriptResults.Success;
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook wb;
wb = excel.Workbooks.Open(#"C:\Test.xlsx",0, false, null, null, null, true, null, null, null, null, null, null, null, null);
//wb.RefreshAll();
//wb.Save();
//wb.Close(null, null, null);
excel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
}
The error message is as follows:
Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
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_2177878595ee4288864728b04a894c16.csproj.ScriptMain.Main()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& 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 Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
I am currently working on my test machine with the following configuration:
Visual Studio 2008 BIDS
Office 2010
Office 2010 PIAs
Does anyone have any suggestions as to how to get this working?
Use Type.Missing in place of null. And also ref before each variable. See http://msdn.microsoft.com/en-us/library/system.type.missing(v=VS.90).aspx