How do I use a DocumentReference with a relative URI

Ribbon for WPF Forum

Posted 9 years ago by Mick
Avatar
When I try to do this, I get an InvalidOperationException.

My project is database driven, so I don't have physical files that I can point to with a syntax like @"C:\Documents\Account.xxx"

my URIs look something like @"/Accounts?id=C1E64B78-F18F-41C5-B328-82CFED667EC8"

Comments (4)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mick,

The exception would be coming from the System.Uri class itself, not from our code. So it would have to conform to whatever spec they allow.

Perhaps try using the constructor that allows a UriKind and specify Relative for that.


Actipro Software Support

Posted 9 years ago by Mick
Avatar
I'm trying to figure out the correct way to use Actipro's RecentDocumentManager.

I'm copying syntax from the sample project in ...\Actipro Software\WPFStudio\v11.1.0542\SampleBrowser\ProductSamples\RibbonSamples\Common\DocumentReferenceGenerator.cs

The exception may originate from the System.Uri class, but something from within Actipro's code is calling the illegal operation (for example, perhaps Actipro assumes the URI is absolute and tries to resolve an absolute path without verifying the UriKind).

Here is some sample code that reproduces the error:

private void TestFunction()
{
    // Create an absolute and a relative URI
    System.Uri absoluteUri = new System.Uri(@"C:\Temp\Account.ABC", System.UriKind.Absolute);
    System.Uri relativeUri = new System.Uri(@"/Account?id=ABC", System.UriKind.Relative);

    // The absolute URI works
    object o1 = new ActiproSoftware.Windows.DocumentManagement.DocumentReference(absoluteUri);
    // The relative URI does not work
    object o2 = new ActiproSoftware.Windows.DocumentManagement.DocumentReference(relativeUri);
}
To use the RecentDocumentManager, the sample project leads me to believe I need to use an Actipro DocumentReference. Is this correct or is there another way to do this?

Mick
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mick,

An exception does occur there since it appears we're trying to access the LocalPath property to set the Name for you. We've updated the code for the next build to only do this if IsAbsoluteUri is true and we've also wrapped the entire thing with a try...catch.


Actipro Software Support

Posted 9 years ago by Mick
Avatar
Cool, thanks.

Mick
The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.