SOAP exception in WPF Application while accessing Web Service - c#

I am learning C#, and in one of the assignment i have to display the data from an Access file into a DataGrid upon button click using a WPF Application, and a web reference.
There is a SOAP Exception which i am not able to resolve, any help is appreciated, thanks in advance -
Web reference asmx file contains the below method, that is called upon button click -
[WebMethod]
public ArrayList queryDB()
{
string selectStmt = "select * from Students";
OleDbConnection conn_obj = new DBConnect().checkDBStatus(databaseLocation);
conn_obj.Open();
OleDbCommand query = new OleDbCommand(selectStmt, conn_obj);
OleDbDataReader dbReader = query.ExecuteReader();
ArrayList dbRecordList = new ArrayList();
foreach (DbDataRecord dbRecord in dbReader)
{
dbRecordList.Add(dbRecord);
}
conn_obj.Close();
return dbRecordList;
}
WPF file code is as below - "Button click method"
private void GetData_Click(object sender, RoutedEventArgs e)
{
ArrayList datagridList = (ArrayList) websrvc.queryDB();
dataGrid.ItemsSource = datagridList;
}
The above code is creating an error - Cannot implicitly convert type 'object[]' to 'System.Collections.ArrayList'
Hence based on a suggestion over web, changed the code as below -
private void GetData_Click(object sender, RoutedEventArgs e)
{
object obj = websrvc.queryDB();
ArrayList datagridList = (ArrayList) obj;
dataGrid.ItemsSource = datagridList;
}
Now, there seems to be no errors, but an exception at the below line of code, which i am not able to solve -
object obj = websrvc.queryDB();
{"System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: System.Data.Common.DataRecordInternal cannot be serialized because it does not have a parameterless constructor.\n at System.Xml.Serialization.TypeDesc.CheckSupported()\n at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)\n at System.Xml.Serialization.XmlSerializationWriter.CreateUnknownTypeException(Type type)\n at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType)\n at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType)\n at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write2_queryDBResponse(Object[] p)\n at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer1.Serialize(Object objectToSerialize, XmlSerializationWriter writer)\n at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)\n --- End of inner exception stack trace ---\n at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)\n at System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)\n at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)\n at System.Web.Services.Protocols.WebServiceHandler.Invoke()\n --- End of inner exception stack trace ---"}

Create a class on web service side named Student with all the properties that you want to send to client.
Mark this class as serializable.
Map the DB object properties one by one to this Student class.
From the service, instead of returning ArrayList, return ArrayList();
Let me know if this works.

Related

ComException HRESULT: 0x800A03EC thrown when attempting to add Validation to a Range

When trying to use the Range.Validation.Add() method, I'm consistently getting a very unfriendly error:
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Microsoft.Office.Interop.Excel.Validation.Add(XlDVType Type, Object AlertStyle, Object Operator, Object Formula1, Object Formula2)
at TravelPlannerTools.Sheet8.OperaCodesDropDown() in C:\Users\Michael Utz\Documents\Visual Studio 2015\Projects\TravelPlannerTools\TravelPlannerTools\Sheet8.cs:line 39
at TravelPlannerTools.Sheet8.Sheet8_Startup(Object sender, EventArgs e) in C:\Users\Michael Utz\Documents\Visual Studio 2015\Projects\TravelPlannerTools\TravelPlannerTools\Sheet8.cs:line 27
at Microsoft.Office.Tools.Excel.WorksheetImpl.OnStartup()
at Microsoft.Office.Tools.Excel.WorksheetImpl.WorksheetExtensionImpl.Microsoft.Office.Tools.EntryPoint.OnStartup()
at Microsoft.Office.Tools.Excel.WorksheetBase.OnStartup()
at TravelPlannerTools.Sheet8.FinishInitialization() in C:\Users\Michael Utz\Documents\Visual Studio 2015\Projects\TravelPlannerTools\TravelPlannerTools\Sheet8.Designer.cs:line 50
at Microsoft.Office.Tools.Excel.WorksheetBase.Microsoft.Office.Tools.EntryPoint.FinishInitialization()
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase(ExecutionPhases executionPhases)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.ExecuteEntryPoints()
************** Loaded Assemblies **************
I am using the proper version of Excel and trying to perform a very simple task.
var list = new List<string>();
list.Add("Lann");
list.Add("Latl");
list.Add("LBBB");
var flatList = string.Join(",", list.ToArray());
var cell = Globals.Sheet8.Cells.Range["A2"];
cell.Validation.Delete();
cell.Validation.Add(
Excel.XlDVType.xlValidateList,
Excel.XlDVAlertStyle.xlValidAlertStop,
Excel.XlFormatConditionOperator.xlBetween,
flatList,
System.Type.Missing
);
cell.Validation.IgnoreBlank = true;
cell.Validation.InCellDropdown = true;
Any ideas?
The cell I was trying to write to was on a protected sheet. Using the Worksheet.Protect() and Worksheet.Unprotect() methods to toggle protection before and after the operation cleared up the error!

Mapping Error In Linq to Lucene.Net

I have the following Document Specs for Use in Linq TO Lucene
public class Doc1
{
public Doc1()
{
Docs = new List<Doc2>();
}
private IList<Doc2> Docs{get;set;}
}
public Class Doc2
{
//whatever
}
The Problem is when I try to Use it like this
var provider = new LuceneDataProvider(directory, Version.LUCENE_30);
using (var session = provider.OpenSession<Doc1>())
{
var m = new Doc1();
session.Add(m);
}
The Problem is when I execute this code, I get the following error
Property Event of type System.Collections.Generic.IList`1[Doc1] cannot be converted from System.String
Please is there another way of doing this
Thanks in advance
Here goes the Full Stack Trace
[NotSupportedException: Property Event of type System.Collections.Generic.IList`1[Doc2] cannot be converted from System.String]
Lucene.Net.Linq.Mapping.FieldMappingInfoBuilder.GetConverter(PropertyInfo p, Type type, FieldAttribute metadata) +487
Lucene.Net.Linq.Mapping.FieldMappingInfoBuilder.BuildPrimitive(PropertyInfo p, Type type, FieldAttribute metadata, Version version, Analyzer externalAnalyzer) +63
Lucene.Net.Linq.Mapping.FieldMappingInfoBuilder.Build(PropertyInfo p, Version version, Analyzer externalAnalyzer) +364
Lucene.Net.Linq.Mapping.ReflectionDocumentMapper`1.BuildFieldMap(IEnumerable`1 props) +184
Lucene.Net.Linq.Mapping.ReflectionDocumentMapper`1..ctor(Version version, Analyzer externalAnalyzer) +77
Lucene.Net.Linq.LuceneDataProvider.OpenSession(ObjectLookup`1 lookup) +67
Lucene.Net.Linq.LuceneDataProvider.OpenSession(ObjectFactory`1 factory) +142
Lucene.Net.Linq.LuceneDataProvider.OpenSession() +114

Unable to read a TSR Object repository using RepositoryUtil.dll in C#

I am pretty new to C# and .net. and I have been tasked with creating a WPF application POC to read a QTP object repository in a .tsr file and populate a TreeView with all the objects in that repository and their child objects.
I was provided with QTP's RepositoryUtil.dll and the following sample code to adapt to C#:
Dim i
Dim ORFile = "D:\TAF\Size.tsr"
Dim ORObj = CreateObject("Mercury.ObjectRepositoryUtil")
ORObj.Load(ORFile)
Dim ObjectCollection = ORObj.GetChildren
For i = 0 To ObjectCollection.Count - 1
Dim Obj = ObjectCollection.Item(i)
Dim temp1 = "" & Obj.GetTOProperty("micclass") & "(""" & ORObj.GetLogicalName(Obj) & """)"
Dim treeItem = New TreeViewItem
Dim tNode = New TreeViewItem() With {.Header = temp1}
treeview1.Items.Add(tNode)
tNode = treeview1.Items(i)
Add(ORObj, Obj, tNode)
Next
Now I am not very familiar with Visual Basic however I am trying to adapt it as follows in a Console application to check whether the string "title" gets populated.
static void Main(string[] args)
{
string ORFilePath = #"D:\TAF\Size.tsr";
ObjectRepositoryUtil ORUtil = new ObjectRepositoryUtil();
ORUtil.Load(ORFilePath);
var ChildObjects = ORUtil.GetChildren();
for (int i = 0; i < ChildObjects.Count(); i++ )
{
var ChildObject = ChildObjects.Item(i);
string title = ChildObject.GetTOProperty("micclass") + "(\"" + ORUtil.GetLogicalName(ChildObject) + "\")";
Console.WriteLine(title);
}
}
But when I run this, I get an InvalidCastException: {"Return argument has an invalid type."} on the line "var ChildObjects = ORUtil.GetChildren();"
I cannot figure out what is wrong or what type is being returned by ORUtil.GetChildren() since there is no documentation provided with the library and I can't find any online.
So, can anyone tell what exactly am I doing wrong here and what is the proper way to go about this?
Edit:
Here's the stack trace for the above exception:
System.InvalidCastException was unhandled
HResult=-2147467262
Message=Return argument has an invalid type.
Source=mscorlib
StackTrace:
at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg, Type paramType)
at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage msg, Object[] outArgs, Object returnValue)
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at REPOSITORYUTILLib.DispIObjectRepositoryUtil.GetChildren(Object Parent)
at ORReader.Program.Main(String[] args) in c:\Users\DDDAVID.DDDAVID-IN\Documents\Visual Studio 2013\Projects\ORReader\ORReader\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
With some help, I've solved my own problem.
What I was trying to do was trying to add the RepositoryUtil.dll as a reference and calling its methods. What I should have been doing was to get the Program Identifier for QTP's registered ObjectRepositoryUtil using the following:
Type.GetTypeFromProgID("Mercury.ObjectRepositoryUtil");
dynamic ORUtil = Activator.CreateInstance(ORType);
I've modified the code as follows and it worked.
static void Main(string[] args)
{
Type ORType = Type.GetTypeFromProgID("Mercury.ObjectRepositoryUtil");
dynamic ORUtil = Activator.CreateInstance(ORType);
string ORFilePath = #"D:\TAF\Size.tsr";
//ObjectRepositoryUtil ORUtil = new ObjectRepositoryUtil();
ORUtil.Load(ORFilePath);
var ChildObjects = ORUtil.GetChildren();
for (int i = 0; i < ChildObjects.Count(); i++ )
{
var ChildObject = ChildObjects.Item(i);
string title = ChildObject.GetTOProperty("micclass") + "(\"" + ORUtil.GetLogicalName(ChildObject) + "\")";
Console.WriteLine(title);
}
}

How to pass parameters for a managed code dll in installshield?

I have a dotnet script which is for encryption and decryption. I have to pass the parameters for the setvalues function in installshield. How can I achieve this? Dotnet code is as follows. I have the assembly (.dll) file.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Security;
using System.Xml;
using System.Collections.Specialized;
namespace EncryptionDecryption
{
public class EncrptionHelper
{
#region Member variables
static byte[] entropy = { 0, 8, 2, 3, 5 };
#endregion
#region Public Methods
public static void SetValue(string configFilePathName, string appSettingKey, string appSettingValue)
{
appSettingValue = EncryptString(ToSecureString(appSettingValue));
SetSetting(appSettingKey, appSettingValue, configFilePathName);
}
public static string GetValue(string configFilePathName, string appSettingKey)
{
string value = GetSetting(appSettingKey, configFilePathName);
value = ToInsecureString( DecryptString(value));
return value;
}
#endregion
#region Private Methods
private static bool SetSetting(string Key, string Value, string configFilePath)
{
bool result = false;
try
{
// System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(configFilePath);
// config.AppSettings.File = configFilePath;
// config.AppSettings.Settings[Key].Value = Value;
// config.Save(ConfigurationSaveMode.Modified);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(configFilePath);
xmlDoc.SelectSingleNode("//appSettings/add[#key='" + Key +"']").Attributes["value"].Value = Value;
xmlDoc.Save(configFilePath);
ConfigurationManager.RefreshSection("appSettings");
result = true;
}
finally
{ }
return result;
}
private static string GetSetting(string Key, string configFilePath)
{
string result = null;
try
{
XmlDocument appSettingsDoc = new XmlDocument();
appSettingsDoc.Load(configFilePath);
XmlNode node = appSettingsDoc.SelectSingleNode("//appSettings");
XmlElement value = (XmlElement)node.SelectSingleNode(string.Format("//add[#key='" + Key + "']"));
result = (value.GetAttribute("value").ToString());
}
finally
{ }
return result;
}
private static SecureString ToSecureString(string input)
{
SecureString secure = new SecureString();
foreach (char c in input)
{
secure.AppendChar(c);
}
secure.MakeReadOnly();
return secure;
}
private static string ToInsecureString(SecureString input)
{
string returnValue = string.Empty;
IntPtr ptr = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(input);
try
{
returnValue = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(ptr);
}
finally
{
System.Runtime.InteropServices.Marshal.ZeroFreeBSTR(ptr);
}
return returnValue;
}
private static string EncryptString(System.Security.SecureString input)
{
byte[] encryptedData = System.Security.Cryptography.ProtectedData.Protect(
System.Text.Encoding.Unicode.GetBytes(ToInsecureString(input)), entropy, System.Security.Cryptography.DataProtectionScope.CurrentUser);
return Convert.ToBase64String(encryptedData);
}
private static SecureString DecryptString(string encryptedData)
{
try
{
byte[] decryptedData = System.Security.Cryptography.ProtectedData.Unprotect(
Convert.FromBase64String(encryptedData),
entropy,
System.Security.Cryptography.DataProtectionScope.CurrentUser);
return ToSecureString(System.Text.Encoding.Unicode.GetString(decryptedData));
}
catch
{
return new SecureString();
}
}
#endregion
}
}
Update: Action start 14:31:36: Encryption.
MSI (c) (84:40) [14:31:36:525]: Invoking remote custom action. DLL: C:\Users\<username>\AppData\Local\Temp\MSIE259.tmp, Entrypoint: m1
InstallShield: Attempting to load through CLR 4 APIs...
InstallShield: Getting meta host...
InstallShield: Enumerating available runtimes...
InstallShield: Highest available runtime: v4.0.30319
InstallShield: Trying to use highest runtime...
InstallShield: Using highest version runtime...
InstallShield: Loading assembly Security.Encryption from resource 4097
InstallShield: Calling method with parameters [(System.String)C:\Program Files (x86)\<Installdir>\<configfilename>.config, (System.String)VWFPassword, (System.String)]
InstallShield: Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files (x86)\<Installdir>\<configfilename>.config'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at Security.Encryption.EncrptionHelper.SetSetting(String appSettingKey, String appsettingValue, String configFilePathName)
at Security.Encryption.EncrptionHelper.SetValue(String configFilePathName, String appSettingKey, String appSettingValue)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType 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 InstallShield.ClrHelper.CustomActionHelper.CallMethod(EntryPointInfo info)
at InstallShield.ClrHelper.CustomActionHelper.RunAction(UInt32 installHandle, Int32 entryNumber, Int64 instanceHandle)
InstallShield: Managed code threw an unhandled exception.
This is the error I receive after doing all that is mentioned in the screenshots below and doing some R&D. The directory mentioned "C:\Program Files (x86)\\.config" exists when the encryption custiom action is being called but it throws an exception.
Yes, it can be done with following steps:
1- write your required functionality in c# installer class (make sure your are using installer class)
2- Compile and add your dll into installshield (recomended create a separate component for this dll)
3- Select component view -> select above component and go to .Net settings section, set the ".Net Installer class" to true. Set the ".net installer class parameters"
Parameters are passed as key/value pair e.g
/targetDirectory="[INSTALLDIR]\"
All steps are same, just added screenshots.
Create a dll with an installer class and your encrypt/decrypt class.
Add dll and config file to component(above mentioned), if config file is already added to some other component then its fine. no need to add again.
I have added and retrieved INSTALLDIR variable as argument which is predefined. if you want to receive some input from user (from some custom textboxes) then you will need to define your own variables to store and pass values as arguments.
Creating dll with installer class and your requred logic for other task
Creating component and adding files
Mark the dll as installer class and pass arguments
Here goes installer class:
using System;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
using System.Configuration.Install;
using System.Collections.Generic;
namespace EncryptionDecryption
{
[RunInstaller(true)]
public class InstallerClassDemo : Installer
{
private string installationDirectory=string.Empty;
private string testString=string.Empty ;
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
try
{
//For testing purpose only.. work only in debug mode when pdb files are deployed as well.
//Debugger.Break();
installationDirectory = Context.Parameters["INSTALLDIR"];
//I believe, the config file must be located in the installation directory if so, then use the following way to compute path
string configFilePath = Path.Combine(installationDirectory, "myConfigFile.config");
EncrptionHelper.SetValue(configFilePath, "testKey", "testValue");
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
protected override void OnCommitted(System.Collections.IDictionary savedState)
{
base.OnCommitted(savedState);
}
public override void Uninstall(System.Collections.IDictionary savedState)
{
base.Uninstall(savedState);
}
}
}
I think installshield cannot (or need extra work) for read your assemblies, but you can run simple console application which consume your assemblies from installscript and passing parameter from installshield.
Create simple console application
Include console application on Support Files
Copy to installation folder or assemblies location, so console application can access your assemblies
Launch from installscript using launchappandwait
If consoleapp.exe not use anymore, just delete it.

SharePoint 2010 - Receiving error attempting to use SPWebConfigModification

I'm creating a SharePoint feature and within my FeatureReceiver I'm attempting to add a SPWebConfigModification. I've been following the approach outlined in this blog post.
Here is a snippet from my feature receiver:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
var webApp = (SPWebApplication)properties.Feature.Parent;
var debugMode = new SPWebConfigModification
{
Path = "configuration/system.web/customErrors",
Name = "mode",
Value = "Off",
Sequence = 0,
Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute,
Owner = "MyWebConfigMods"
};
webApp.WebConfigModifications.Add(debugMode); // <------ Error is thrown at this line
webApp.WebService.ApplyWebConfigModifications();
webApp.Update();
}
Here is the stack trace from the error as seen in the SharePoint ULS viewer:
Feature receiver assembly 'MyCompany.SharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxx', class 'MyCompany.SharePoint.Features.WebConfig.WebConfigFeatureReceiver', method 'FeatureActivated' for feature '3a07b91c-0968-4f14-b2bc-ae0e3f109cf9' threw an exception: System.Xml.XPath.XPathException: '' is an invalid expression.
at MS.Internal.Xml.XPath.XPathScanner..ctor(String xpathExpr)
at MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(String xpathExpresion)
at MS.Internal.Xml.XPath.QueryBuilder.Build(String query, Boolean allowVar, Boolean allowKey)
at System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver)
at System.Xml.XPath.XPathNavigator.Select(String xpath)
at System.Xml.XmlNode.SelectSingleNode(String xpath)
at Microsoft.SharePoint.Administration.SPWebConfigFileChanges.ApplyModificationsWebConfigXmlDocument(XmlDocument xdWebConfig, String filepath)
at Microsoft.SharePoint.Administration.SPWebApplication.ApplyWebConfigModifications()
at Microsoft.SharePoint.Administration.SPWebService.ApplyWebConfigModifications()
at MyCompany.SharePoint.WebConfigModificationFeatureReceiver.FeatureActivated(SPFeatureReceiverProperties properties)
at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce)
Somewhere during the update an empty path is being referenced within an XPath expression. It's not in my feature. Any ideas?
customErrors does not have an attribute named debug, you must be referring to compilation element
This is the code we use:
SPWebApplication wappCurrent = (SPWebApplication)properties.Feature.Parent;
SPWebConfigModification modAuthorizedType = new SPWebConfigModification();
modAuthorizedType.Name = "authorizedType[#Assembly='Infowise.AssociatedTasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=23853b1f8d5855a5']";
modAuthorizedType.Owner = "Infowise.Actions";
modAuthorizedType.Path = "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes";
modAuthorizedType.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
modAuthorizedType.Value = #"<authorizedType Assembly=""Infowise.AssociatedTasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=23853b1f8d5855a5"" Namespace=""Infowise.Sharepoint.V3.Fields.Workflow"" TypeName=""*"" Authorized=""True"" />";
wappCurrent.WebConfigModifications.Add(modAuthorizedType);
wappCurrent.Update();
wappCurrent.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
Hope if helps
In my case, wappCurrent.WebConfigModifications had some old values with an invalid Path property. Clearing the array fixed the problem.

Categories