System.IO.DirectoryNotFoundException: Could not find a parth of the path - c#

I'm working with MRTK in Unity and I'm trying to access the namespace Microsoft.MixedReality in a script, but I get the error that MixedRealty doesn't exist at Microsoft namespace. However, at the MixedReality script all the namespaces are found, which troubles me for not knowing how to access the namespace.
At the same time, I'm getting this error at the console log:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\User\Documents\cummins-loto\Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation#a77cb7137a89-1660746982947\SDK\Experimental\InteractiveElement\Examples\Scripts\CustomStateExample\KeyboardState'.
at System.IO.__Error.WinIOError (System.Int32 errorCode, System.String maybeFullPath) [0x000f7] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.FileSystemEnumerableIterator1[TSource].HandleError (System.Int32 hr, System.String path) [0x00006] in <695d1cc93cca45069c528c15c9fdd749>:0 at System.IO.FileSystemEnumerableIterator1[TSource].CommonInit () [0x00054] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.FileSystemEnumerableIterator1[TSource]..ctor (System.String path, System.String originalUserPath, System.String searchPattern, System.IO.SearchOption searchOption, System.IO.SearchResultHandler1[TSource] resultHandler, System.Boolean checkHost) [0x000d6] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.FileSystemEnumerableFactory.CreateFileNameIterator (System.String path, System.String originalUserPath, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) [0x00009] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.Directory.InternalGetFileDirectoryNames (System.String path, System.String userPathOriginal, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.Directory.InternalGetFiles (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x0001c] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.DirectoryInfo.GetFiles (System.String searchPattern) [0x0000e] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x00002] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.DirectoryInfo.GetFiles (System.String searchPattern, System.IO.SearchOption searchOption) [0x00017] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFiles(string,System.IO.SearchOption)
at Microsoft.MixedReality.Toolkit.Utilities.Editor.OnLoadUtilities.FindShaderFolderInPackage () [0x0005f] in C:\Users\User\Documents\cummins loto\Library\PackageCache\com.microsoft.mixedreality.toolkit.standardassets#52286f91c474-1660746983015\EditorUtilities\OnLoadUtilities.cs:152
at Microsoft.MixedReality.Toolkit.Utilities.Editor.OnLoadUtilities.EnsureShaders (System.Boolean bypassIgnore) [0x00001] in C:\Users\User\Documents\cummins-loto\Library\PackageCache\com.microsoft.mixedreality.toolkit.standardassets#52286f91c474-1660746983015\EditorUtilities\OnLoadUtilities.cs:42
at Microsoft.MixedReality.Toolkit.Utilities.Editor.OnLoadUtilities..cctor () [0x00001] in C:\Users\User\Documents\cummins-loto\Library\PackageCache\com.microsoft.mixedreality.toolkit.standardassets#52286f91c474-1660746983015\EditorUtilities\OnLoadUtilities.cs:23
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[])
I don't know what do I have to do to fix that error, I've tried reimporting all assets, regenerating project files, moving the script on which I need to access the namespace to another and erasing the Library folder, but hasn't worked. I hope someone knows a solution!
Thanks in advance.

Related

App Crashing after indegrating Audience Network Ads in Unity 2021.3.6f1

i am getting this error when i play the game in editor after integrating Audience network Ads:
Exception: Field currentActivity or type signature not found
UnityEngine._AndroidJNIHelper.GetFieldID (System.IntPtr jclass, System.String fieldName, System.String signature, System.Boolean isStatic) (at <9d0861ca66fe45e696ddf3e3a8d9ea41>:0)
UnityEngine.AndroidJNIHelper.GetFieldID (System.IntPtr javaClass, System.String fieldName, System.String signature, System.Boolean isStatic) (at <9d0861ca66fe45e696ddf3e3a8d9ea41>:0)
UnityEngine._AndroidJNIHelper.GetFieldID[ReturnType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at <9d0861ca66fe45e696ddf3e3a8d9ea41>:0)
UnityEngine.AndroidJNIHelper.GetFieldID[FieldType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at <9d0861ca66fe45e696ddf3e3a8d9ea41>:0)
UnityEngine.AndroidJavaObject._GetStatic[FieldType] (System.String fieldName) (at <9d0861ca66fe45e696ddf3e3a8d9ea41>:0)
UnityEngine.AndroidJavaObject.GetStatic[FieldType] (System.String fieldName) (at <9d0861ca66fe45e696ddf3e3a8d9ea41>:0)
AudienceNetwork.AudienceNetworkAds.IsInitialized () (at Assets/AudienceNetwork/Library/AudienceNetworkAds.cs:33)
AudienceNetwork.AudienceNetworkAds.Initialize () (at Assets/AudienceNetwork/Library/AudienceNetworkAds.cs:15)
AudienceNetwork.AdView..ctor (System.String placementId, AudienceNetwork.AdSize size) (at Assets/AudienceNetwork/Library/AdView.cs:114)
AdsManager.LoadBanner () (at Assets/Scripts/AdsManager.cs:27)
AdsManager.Start () (at Assets/Scripts/AdsManager.cs:12)
Snreenshot
Screenshot
Screenshot

Entity Framework Core SaveChanges causes error on Mac

I'm currently trying to build an EF core project, but when I call db.SaveChanges() I get the following error:
System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.InOutOfProcHelper' threw an exception. ---> System.EntryPointNotFoundException: GetModuleHandle assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Microsoft.Data.Common.SafeNativeMethods.GetModuleHandle(string)
at Microsoft.Data.SqlClient.InOutOfProcHelper..ctor () [0x00006] in <a1c8e16fd44948ee8c6a463f125e71f0>:0
at Microsoft.Data.SqlClient.InOutOfProcHelper..cctor () [0x00000] in <a1c8e16fd44948ee8c6a463f125e71f0>:0
--- End of inner exception stack trace ---
at Microsoft.Data.SqlClient.SqlConnectionString..ctor (System.String connectionString) [0x0000d] in <a1c8e16fd44948ee8c6a463f125e71f0>:0
at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions (System.String connectionString, Microsoft.Data.Common.DbConnectionOptions previous) [0x00000] in <a1c8e16fd44948ee8c6a463f125e71f0>:0
at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup (Microsoft.Data.Common.DbConnectionPoolKey key, Microsoft.Data.ProviderBase.DbConnectionPoolGroupOptions poolOptions, Microsoft.Data.Common.DbConnectionOptions& userConnectionOptions) [0x0003e] in <a1c8e16fd44948ee8c6a463f125e71f0>:0
at Microsoft.Data.SqlClient.SqlConnection.ConnectionString_Set (Microsoft.Data.Common.DbConnectionPoolKey key) [0x00008] in <a1c8e16fd44948ee8c6a463f125e71f0>:0
at Microsoft.Data.SqlClient.SqlConnection.set_ConnectionString (System.String value) [0x0006b] in <a1c8e16fd44948ee8c6a463f125e71f0>:0
at Microsoft.Data.SqlClient.SqlConnection..ctor (System.String connectionString, Microsoft.Data.SqlClient.SqlCredential credential) [0x00006] in <a1c8e16fd44948ee8c6a463f125e71f0>:0
at Microsoft.Data.SqlClient.SqlConnection..ctor (System.String connectionString) [0x00000] in <a1c8e16fd44948ee8c6a463f125e71f0>:0
at (wrapper remoting-invoke-with-check) Microsoft.Data.SqlClient.SqlConnection..ctor(string)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection () [0x00006] in <5c775909c1cf40629fd2452310cf8cc1>:0
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection () [0x0000a] in <5314a29febc14288a1bc53bf7b46d725>:0
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.CreateCommand (Microsoft.EntityFrameworkCore.Storage.RelationalCommandParameterObject parameterObject, System.Guid commandId, Microsoft.EntityFrameworkCore.Diagnostics.DbCommandMethod commandMethod) [0x0005c] in <5314a29febc14288a1bc53bf7b46d725>:0
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader (Microsoft.EntityFrameworkCore.Storage.RelationalCommandParameterObject parameterObject) [0x00027] in <5314a29febc14288a1bc53bf7b46d725>:0
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1+Enumerator[T].InitializeReader (Microsoft.EntityFrameworkCore.DbContext _, System.Boolean result) [0x00050] in <5314a29febc14288a1bc53bf7b46d725>:0
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult] (TState state, System.Func`3[T1,T2,TResult] operation, System.Func`3[T1,T2,TResult] verifySucceeded) [0x00011] in <5c775909c1cf40629fd2452310cf8cc1>:0
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1+Enumerator[T].MoveNext () [0x00193] in <5314a29febc14288a1bc53bf7b46d725>:0
at System.Linq.Enumerable.SingleOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00041] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq/src/System/Linq/Single.cs:104
at (wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure,Microsoft.EntityFrameworkCore.Query.QueryContext)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult] (System.Linq.Expressions.Expression query) [0x00075] in <a3dbe48366454fdbb51dfeeb0b5c4997>:0
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult] (System.Linq.Expressions.Expression expression) [0x00000] in <a3dbe48366454fdbb51dfeeb0b5c4997>:0
at System.Linq.Queryable.FirstOrDefault[TSource] (System.Linq.IQueryable`1[T] source) [0x0000e] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq.Queryable/src/System/Linq/Queryable.cs:729
at GenericEFIAPI.RTATenantsDatabaseHelper.convertTenant (System.String tenantId, GenericEFIAPI.configObject config, GenericEFIAPI.models.TenantDatabase db) [0x002d2] in /Users/jft/projects/GenericAPI/GenericEFIAPI/RTATenantsDatabaseHelper.cs:108
at GenericEFIAPI.Program+<>c__DisplayClass1_0.<Main>b__0 (GenericEFIAPI.Program+Options o) [0x000c1] in /Users/jft/projects/GenericAPI/GenericEFIAPI/Program.cs:78
at CommandLine.ParserResultExtensions.WithParsed[T] (CommandLine.ParserResult`1[T] result, System.Action`1[T] action) [0x00011] in <68c69d6559fd42bc897efd2a474dfda9>:0
at GenericEFIAPI.Program.Main (System.String[] args) [0x00013] in /Users/jft/projects/GenericAPI/GenericEFIAPI/Program.cs:38
I've tried looking around on google for some help, but have come up empty so far... Anybody have any ideas? I'm trying to connect to sql server and using DbContextOptionsBuilder().UseSqlServer() for the underlying connection.
I'm currently getting my old windows laptop up and running to see if it is because I'm on a Mac or not, but I thought I would get this question out there in the mean time.
Alright! So I'm not 100% sure why my connection string is failing when passing it directly to the DbContextOptionsBuilder().UseSqlServer(connectionString), but if I create a SqlConnection object before that, and pass that as the parameter to UseSqlServer, it works.
So got a workaround, but not sure why the error happens when just passing the connection string.

How to handle UnauthorizedAccessException when starting a FileSystemWatcher

I'm getting an error when starting a FileSystemWatcher for a path that contains an inaccessible folder.
The folder is not accessible even by file system, if I try to access it I get a popup message asking me to grant permanent access to my user, this is completely fine but I'd like to handle it in my application to correctly start the watcher.
_watcher = new FileSystemWatcher(_path, _filter)
{
IncludeSubdirectories = true,
NotifyFilter = NotifyFilters.LastAccess
| NotifyFilters.LastWrite
| NotifyFilters.FileName
| NotifyFilters.DirectoryName
};
_watcher.Changed += new FileSystemEventHandler(OnChanged);
_watcher.Created += new FileSystemEventHandler(OnCreated);
_watcher.Deleted += new FileSystemEventHandler(OnDeleted);
_watcher.Renamed += new RenamedEventHandler(OnRenamed);
_watcher.EnableRaisingEvents = true;
The exception I'm getting is this
UnauthorizedAccessException: Access to the path 'D:\some_folder' is denied.
System.IO.__Error.WinIOError (System.Int32 errorCode, System.String maybeFullPath) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.IO.FileSystemEnumerableIterator`1[TSource].HandleError (System.Int32 hr, System.String path) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.IO.FileSystemEnumerableIterator`1[TSource].CommonInit () (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.IO.FileSystemEnumerableIterator`1[TSource]..ctor (System.String path, System.String originalUserPath, System.String searchPattern, System.IO.SearchOption searchOption, System.IO.SearchResultHandler`1[TSource] resultHandler, System.Boolean checkHost) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.IO.FileSystemEnumerableFactory.CreateFileNameIterator (System.String path, System.String originalUserPath, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.IO.Directory.InternalGetFileDirectoryNames (System.String path, System.String userPathOriginal, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.IO.Directory.InternalGetDirectories (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.IO.Directory.GetDirectories (System.String path) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, System.Boolean dispatch) (at <4b9f316768174388be8ae5baf2e6cc02>:0)
System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, System.Boolean dispatch) (at <4b9f316768174388be8ae5baf2e6cc02>:0)
System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, System.Boolean dispatch) (at <4b9f316768174388be8ae5baf2e6cc02>:0)
System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, System.Boolean dispatch) (at <4b9f316768174388be8ae5baf2e6cc02>:0)
System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, System.Boolean dispatch) (at <4b9f316768174388be8ae5baf2e6cc02>:0)
System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, System.Boolean dispatch) (at <4b9f316768174388be8ae5baf2e6cc02>:0)
System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, System.Boolean dispatch) (at <4b9f316768174388be8ae5baf2e6cc02>:0)
System.IO.DefaultWatcher.UpdateDataAndDispatch (System.IO.DefaultWatcherData data, System.Boolean dispatch) (at <4b9f316768174388be8ae5baf2e6cc02>:0)
System.IO.DefaultWatcher.StartDispatching (System.IO.FileSystemWatcher fsw) (at <4b9f316768174388be8ae5baf2e6cc02>:0)
System.IO.FileSystemWatcher.Start () (at <4b9f316768174388be8ae5baf2e6cc02>:0)
System.IO.FileSystemWatcher.set_EnableRaisingEvents (System.Boolean value) (at <4b9f316768174388be8ae5baf2e6cc02>:0)
(wrapper remoting-invoke-with-check) System.IO.FileSystemWatcher.set_EnableRaisingEvents(bool)
The paths exists, it's inside an usb key for which I have read/write permissions, it's only a specific folder which raises the issue.
Is there a way to safely catch this exception and start the watcher?
You could first check the permissions:
public static bool HasWritePermissionOnDir(string path)
{
var writeAllow = false;
var writeDeny = false;
var accessControlList = Directory.GetAccessControl(path);
if (accessControlList == null)
return false;
var accessRules = accessControlList.GetAccessRules(true, true,
typeof(System.Security.Principal.SecurityIdentifier));
if (accessRules ==null)
return false;
foreach (FileSystemAccessRule rule in accessRules)
{
if ((FileSystemRights.Write & rule.FileSystemRights) != FileSystemRights.Write)
continue;
if (rule.AccessControlType == AccessControlType.Allow)
writeAllow = true;
else if (rule.AccessControlType == AccessControlType.Deny)
writeDeny = true;
}
return writeAllow && !writeDeny;
}

Exception thrown when using Mono+Aspose.Words running on ubuntu

I'm using Aspose.Words to convert a doc/docx file to a pdf file on ubuntu. Mono runtime has been installed. My code is below:
Document doc = new Document ("/data/upfile/test.docx");
doc.Save ("/data/upfile/test.pdf", SaveFormat.Pdf);
Somehow, when the second line of the code is executed, an error was thrown. The detail is below:
Unhandled Exception: System.ArgumentOutOfRangeException: startIndex +
length > this.length Parameter name: length at
System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in
:0 at
x6c95d9cf46ff5f25.x0d299f323d241756.x3b67e683e83cab62 (System.String
xe4115acdf4fbfccc, Int32 x961016a387451f05) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x4469479613bec4d8
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x7be41bff00df2c71
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x699caa1974f95d1a
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x21e4bd206d6231f8
(System.Object xa860e35844c20ac7) [0x00000] in :0
at x4adf554d20d941a6.x50e6e6d123fa4a35.xb5ef8a04e65b87e6
(System.String x1f25abf5fb75e795, System.Object xa860e35844c20ac7)
[0x00000] in :0 at
x59d6a4fc5007b7a4.xdeb77ea37ad74c56.xbbf9a1ead81dd3a1 (System.String
x1f25abf5fb75e795, System.Object xa860e35844c20ac7) [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.xbbf9a1ead81dd3a1 (System.String
x1f25abf5fb75e795, System.Object xa860e35844c20ac7) [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.xf3a1cfbffa44728c () [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.x47f176deff0d42e2 () [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.x83f07df6a659e05b () [0x00000] in
:0 at
x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98
(Aspose.Words.Document x3664041d21d73fdc,
x59d6a4fc5007b7a4.xdeb77ea37ad74c56 xdfde339da46db651) [0x00000] in
:0 at Aspose.Words.Document.UpdatePageLayout ()
[0x00000] in :0 at
Aspose.Words.Document.x410db0f4a89a6ef1 (Boolean x24af0daafcd8fb8c)
[0x00000] in :0 at
Aspose.Words.Document.get_xcde671c53995c411 () [0x00000] in :0 at Aspose.Words.Document.get_PageCount () [0x00000] in
:0 at
xf989f31a236ff98c.x6c74398bceb133f8.xa2e0b7f7da663553
(x28925c9b27b37a46.x8556eed81191af11 x5ac1382edb7bf2c2) [0x00000] in
:0 at Aspose.Words.Document.xf381a641001e6830
(System.IO.Stream xcf18e5243f8d5fd3, System.String xafe2f3653ee64ebc,
Aspose.Words.Saving.SaveOptions xc27f01f21f67608c) [0x00000] in
:0 at Aspose.Words.Document.Save (System.String
fileName, Aspose.Words.Saving.SaveOptions saveOptions) [0x00000] in
:0 at Aspose.Words.Document.Save (System.String
fileName, SaveFormat saveFormat) [0x00000] in :0
at MonoTest.MainClass.Main (System.String[] args) [0x00000] in
:0 [ERROR] FATAL UNHANDLED EXCEPTION:
System.ArgumentOutOfRangeException: startIndex + length > this.length
Parameter name: length at System.String.Substring (Int32 startIndex,
Int32 length) [0x00000] in :0 at
x6c95d9cf46ff5f25.x0d299f323d241756.x3b67e683e83cab62 (System.String
xe4115acdf4fbfccc, Int32 x961016a387451f05) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x4469479613bec4d8
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x7be41bff00df2c71
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x699caa1974f95d1a
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x21e4bd206d6231f8
(System.Object xa860e35844c20ac7) [0x00000] in :0
at x4adf554d20d941a6.x50e6e6d123fa4a35.xb5ef8a04e65b87e6
(System.String x1f25abf5fb75e795, System.Object xa860e35844c20ac7)
[0x00000] in :0 at
x59d6a4fc5007b7a4.xdeb77ea37ad74c56.xbbf9a1ead81dd3a1 (System.String
x1f25abf5fb75e795, System.Object xa860e35844c20ac7) [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.xbbf9a1ead81dd3a1 (System.String
x1f25abf5fb75e795, System.Object xa860e35844c20ac7) [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.xf3a1cfbffa44728c () [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.x47f176deff0d42e2 () [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.x83f07df6a659e05b () [0x00000] in
:0 at
x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98
(Aspose.Words.Document x3664041d21d73fdc,
x59d6a4fc5007b7a4.xdeb77ea37ad74c56 xdfde339da46db651) [0x00000] in
:0 at Aspose.Words.Document.UpdatePageLayout ()
[0x00000] in :0 at
Aspose.Words.Document.x410db0f4a89a6ef1 (Boolean x24af0daafcd8fb8c)
[0x00000] in :0 at
Aspose.Words.Document.get_xcde671c53995c411 () [0x00000] in :0 at Aspose.Words.Document.get_PageCount () [0x00000] in
:0 at
xf989f31a236ff98c.x6c74398bceb133f8.xa2e0b7f7da663553
(x28925c9b27b37a46.x8556eed81191af11 x5ac1382edb7bf2c2) [0x00000] in
:0 at Aspose.Words.Document.xf381a641001e6830
(System.IO.Stream xcf18e5243f8d5fd3, System.String xafe2f3653ee64ebc,
Aspose.Words.Saving.SaveOptions xc27f01f21f67608c) [0x00000] in
:0 at Aspose.Words.Document.Save (System.String
fileName, Aspose.Words.Saving.SaveOptions saveOptions) [0x00000] in
:0 at Aspose.Words.Document.Save (System.String
fileName, SaveFormat saveFormat) [0x00000] in :0
at MonoTest.MainClass.Main (System.String[] args) [0x00000] in
:0
Any advice is appreciated. Thanks.
Often inner exceptions is a very common problem for converting words documents in PDF via Aspose.
It can be due to some reasones like:
2013 MS Word office.
Some complex elements in word
Old version of Aspose.Words.dll.
Solutions:
Try to update Aspose.Words.dll to new version. If it's still not working - write to aspose forum, and this error will be fixed in new release.
Check word document itself. may be you can find something thac call this inner exception, than try to remove it and check again. If this is acceptable of course.

Processing Linq XML string

I need to parse XML string with Linq, and I came up with the following code.
using System;
using System.Linq;
using System.Xml.Linq;
class LinqXml
{
public void Parse(string input)
{
XDocument xdoc = XDocument.Load(input);
var lang = from d in xdoc.Elements("PipeUnit").Elements("Step").Elements("Pipelist").Elements("NamedPipe").Elements("NameOfPipe") select d;
Console.WriteLine(lang.First().Value);
foreach (var item in lang)
{
Console.WriteLine(item.Value);
}
}
static void Main()
{
string tempString = #"
<PipeUnit>
<Step>
<Pipelist>
<NamedPipe>
<NameOfPipe>Name</NameOfPipe>
<PipeData>Data</PipeData>
</NamedPipe>
</Pipelist>
</Step>
</PipeUnit>
";
var linqXml = new LinqXml();
linqXml.Parse(tempString);
}
}
When compile this code with Mono - dmcs linqxml.cs /r:System.Xml.Linq.dll, and tried to run, I got the following errors.
Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path "/Users/smcho/Desktop/csharp/
<PipeUnit>
<Step>
<Pipelist>
<NamedPipe>
<NameOfPipe>Name</NameOfPipe>
<PipeData>Data</PipeData>
</NamedPipe>
</Pipelist>
</Step>
<PipeUnit>".
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
at System.Xml.XmlUrlResolver.GetEntity (System.Uri absoluteUri, System.String role, System.Type ofObjectToReturn) [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.GetStreamFromUrl (System.String url, System.String& absoluteUriString) [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader..ctor (Boolean dummy, System.Xml.XmlResolver resolver, System.String url, XmlNodeType fragType, System.Xml.XmlParserContext context) [0x00000] in <filename unknown>:0
at System.Xml.XmlTextReader..ctor (Boolean dummy, System.Xml.XmlResolver resolver, System.String url, XmlNodeType fragType, System.Xml.XmlParserContext context) [0x00000] in <filename unknown>:0
at System.Xml.XmlReader.Create (System.String url, System.Xml.XmlReaderSettings settings, System.Xml.XmlParserContext context) [0x00000] in <filename unknown>:0
at System.Xml.XmlReader.Create (System.String url, System.Xml.XmlReaderSettings settings) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Load (System.String uri, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Load (System.String uri) [0x00000] in <filename unknown>:0
at LinqXml.Parse (System.String input) [0x00000] in <filename unknown>:0
at LinqXml.Main () [0x00000] in <filename unknown>:0
What might be wrong?
Replace this:
XDocument xdoc = XDocument.Load(input);
with:
XDocument xdoc = XDocument.Parse(input);
you are passing XML, not a file name.
in your Parse method, you want
XDocument.Parse(input)
Replace
XDocument xdoc = XDocument.Load(input);
with
XDocument xdoc = XDocument.Parse(input);

Categories