WinRTError: Unknown runtime error when referencing a c# component from javascript
up vote
3
down vote
favorite
I'm attempting to access a C# component in UWP, but I get an unhelpful error when doing so: WinRTError: Unknown runtime error. Why does this error occur, and how can I stop it?
I'm using Windows 10, VS 2017, and building my project to meet the minimum version of 10.0.16299.0
Here's a MVCE showing the behavior: https://github.com/re-jim/UWPComponentSample
The C# component is set as a reference in my Javascript component.
Javascript:
The below function triggers the C# component, which should zip a directory
async zip(content) {
try {
console.log('ZipComponent is ', ZipComponent)
console.log('function is ', ZipComponent.ZipWorker.zipDirectory)
ZipComponent.ZipWorker.zipDirectory(content.dirPath, content.dirPath + '\file.ezdrm')
} catch (err) {
console.log('err is ',err)
}
}
I've console.logged the component and the method I intend to use to show that exists:

C#
using System;
using System.Diagnostics;
using System.IO.Compression;
namespace ZipComponent
{
public sealed class ZipWorker
{
public static void ZipDirectory(string folderPath, string outputFile)
{
try
{
Debug.WriteLine("zippping " + folderPath + " output " + outputFile);
ZipFile.CreateFromDirectory(folderPath, outputFile);
}
catch (Exception e)
{
Debug.Write(e);
}
}
public static void UnzipDirectory(string zipFile, string outputPath)
{
try
{
Debug.WriteLine("unzippping " + zipFile + " output " + outputPath);
ZipFile.ExtractToDirectory(zipFile, outputPath);
}
catch (Exception e)
{
Debug.Write(e);
}
}
}
}
I don't see the output from Debug.WriteLine in my output
The code inside of ZipDirectory() doesn't seem to be causing the error. I replaced the function with:
public static string ZipDirectory(){
return "hello world"
}
after also editing the javascript function call to match, And that gives me the same error as below.
Stack trace:
"WinRTError: Unknown runtime error
at ZipService.prototype.zip (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/zip.service.js:12:13)
at Generator.prototype.next (native code)
at onZipRequest (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/wrapperMain.js:69:9)
at Generator.prototype.next (native code)
at SafeSubscriber.prototype.__tryOrUnsub (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:477:13)
at SafeSubscriber.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:415:17)
at Subscriber.prototype._next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:359:9)
at Subscriber.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:336:13)
at Subject.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:755:17)
at AppShellService.prototype.zipContent (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/main.js:197:13)"
javascript c# uwp windows-10-universal
|
show 4 more comments
up vote
3
down vote
favorite
I'm attempting to access a C# component in UWP, but I get an unhelpful error when doing so: WinRTError: Unknown runtime error. Why does this error occur, and how can I stop it?
I'm using Windows 10, VS 2017, and building my project to meet the minimum version of 10.0.16299.0
Here's a MVCE showing the behavior: https://github.com/re-jim/UWPComponentSample
The C# component is set as a reference in my Javascript component.
Javascript:
The below function triggers the C# component, which should zip a directory
async zip(content) {
try {
console.log('ZipComponent is ', ZipComponent)
console.log('function is ', ZipComponent.ZipWorker.zipDirectory)
ZipComponent.ZipWorker.zipDirectory(content.dirPath, content.dirPath + '\file.ezdrm')
} catch (err) {
console.log('err is ',err)
}
}
I've console.logged the component and the method I intend to use to show that exists:

C#
using System;
using System.Diagnostics;
using System.IO.Compression;
namespace ZipComponent
{
public sealed class ZipWorker
{
public static void ZipDirectory(string folderPath, string outputFile)
{
try
{
Debug.WriteLine("zippping " + folderPath + " output " + outputFile);
ZipFile.CreateFromDirectory(folderPath, outputFile);
}
catch (Exception e)
{
Debug.Write(e);
}
}
public static void UnzipDirectory(string zipFile, string outputPath)
{
try
{
Debug.WriteLine("unzippping " + zipFile + " output " + outputPath);
ZipFile.ExtractToDirectory(zipFile, outputPath);
}
catch (Exception e)
{
Debug.Write(e);
}
}
}
}
I don't see the output from Debug.WriteLine in my output
The code inside of ZipDirectory() doesn't seem to be causing the error. I replaced the function with:
public static string ZipDirectory(){
return "hello world"
}
after also editing the javascript function call to match, And that gives me the same error as below.
Stack trace:
"WinRTError: Unknown runtime error
at ZipService.prototype.zip (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/zip.service.js:12:13)
at Generator.prototype.next (native code)
at onZipRequest (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/wrapperMain.js:69:9)
at Generator.prototype.next (native code)
at SafeSubscriber.prototype.__tryOrUnsub (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:477:13)
at SafeSubscriber.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:415:17)
at Subscriber.prototype._next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:359:9)
at Subscriber.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:336:13)
at Subject.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:755:17)
at AppShellService.prototype.zipContent (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/main.js:197:13)"
javascript c# uwp windows-10-universal
Could you show me that how do you get zippedfolderPathparameter ?
– Nico Zhu - MSFT
Nov 13 at 2:01
As you know, uwp runs in sandbox, you could not pass folder path directly. unless you have addedbroadFileSystemAccesscapability.
– Nico Zhu - MSFT
Nov 13 at 2:19
ok, I will check it.
– Nico Zhu - MSFT
Nov 13 at 2:43
Have you checked this document ?
– Nico Zhu - MSFT
Nov 13 at 2:46
1
Yes, I have tested the code sample, and could reproduce the issue. I have reported this issue to related team.
– Nico Zhu - MSFT
Nov 15 at 2:27
|
show 4 more comments
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I'm attempting to access a C# component in UWP, but I get an unhelpful error when doing so: WinRTError: Unknown runtime error. Why does this error occur, and how can I stop it?
I'm using Windows 10, VS 2017, and building my project to meet the minimum version of 10.0.16299.0
Here's a MVCE showing the behavior: https://github.com/re-jim/UWPComponentSample
The C# component is set as a reference in my Javascript component.
Javascript:
The below function triggers the C# component, which should zip a directory
async zip(content) {
try {
console.log('ZipComponent is ', ZipComponent)
console.log('function is ', ZipComponent.ZipWorker.zipDirectory)
ZipComponent.ZipWorker.zipDirectory(content.dirPath, content.dirPath + '\file.ezdrm')
} catch (err) {
console.log('err is ',err)
}
}
I've console.logged the component and the method I intend to use to show that exists:

C#
using System;
using System.Diagnostics;
using System.IO.Compression;
namespace ZipComponent
{
public sealed class ZipWorker
{
public static void ZipDirectory(string folderPath, string outputFile)
{
try
{
Debug.WriteLine("zippping " + folderPath + " output " + outputFile);
ZipFile.CreateFromDirectory(folderPath, outputFile);
}
catch (Exception e)
{
Debug.Write(e);
}
}
public static void UnzipDirectory(string zipFile, string outputPath)
{
try
{
Debug.WriteLine("unzippping " + zipFile + " output " + outputPath);
ZipFile.ExtractToDirectory(zipFile, outputPath);
}
catch (Exception e)
{
Debug.Write(e);
}
}
}
}
I don't see the output from Debug.WriteLine in my output
The code inside of ZipDirectory() doesn't seem to be causing the error. I replaced the function with:
public static string ZipDirectory(){
return "hello world"
}
after also editing the javascript function call to match, And that gives me the same error as below.
Stack trace:
"WinRTError: Unknown runtime error
at ZipService.prototype.zip (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/zip.service.js:12:13)
at Generator.prototype.next (native code)
at onZipRequest (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/wrapperMain.js:69:9)
at Generator.prototype.next (native code)
at SafeSubscriber.prototype.__tryOrUnsub (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:477:13)
at SafeSubscriber.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:415:17)
at Subscriber.prototype._next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:359:9)
at Subscriber.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:336:13)
at Subject.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:755:17)
at AppShellService.prototype.zipContent (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/main.js:197:13)"
javascript c# uwp windows-10-universal
I'm attempting to access a C# component in UWP, but I get an unhelpful error when doing so: WinRTError: Unknown runtime error. Why does this error occur, and how can I stop it?
I'm using Windows 10, VS 2017, and building my project to meet the minimum version of 10.0.16299.0
Here's a MVCE showing the behavior: https://github.com/re-jim/UWPComponentSample
The C# component is set as a reference in my Javascript component.
Javascript:
The below function triggers the C# component, which should zip a directory
async zip(content) {
try {
console.log('ZipComponent is ', ZipComponent)
console.log('function is ', ZipComponent.ZipWorker.zipDirectory)
ZipComponent.ZipWorker.zipDirectory(content.dirPath, content.dirPath + '\file.ezdrm')
} catch (err) {
console.log('err is ',err)
}
}
I've console.logged the component and the method I intend to use to show that exists:

C#
using System;
using System.Diagnostics;
using System.IO.Compression;
namespace ZipComponent
{
public sealed class ZipWorker
{
public static void ZipDirectory(string folderPath, string outputFile)
{
try
{
Debug.WriteLine("zippping " + folderPath + " output " + outputFile);
ZipFile.CreateFromDirectory(folderPath, outputFile);
}
catch (Exception e)
{
Debug.Write(e);
}
}
public static void UnzipDirectory(string zipFile, string outputPath)
{
try
{
Debug.WriteLine("unzippping " + zipFile + " output " + outputPath);
ZipFile.ExtractToDirectory(zipFile, outputPath);
}
catch (Exception e)
{
Debug.Write(e);
}
}
}
}
I don't see the output from Debug.WriteLine in my output
The code inside of ZipDirectory() doesn't seem to be causing the error. I replaced the function with:
public static string ZipDirectory(){
return "hello world"
}
after also editing the javascript function call to match, And that gives me the same error as below.
Stack trace:
"WinRTError: Unknown runtime error
at ZipService.prototype.zip (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/zip.service.js:12:13)
at Generator.prototype.next (native code)
at onZipRequest (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/wrapperMain.js:69:9)
at Generator.prototype.next (native code)
at SafeSubscriber.prototype.__tryOrUnsub (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:477:13)
at SafeSubscriber.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:415:17)
at Subscriber.prototype._next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:359:9)
at Subscriber.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:336:13)
at Subject.prototype.next (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/rxjs/rxjs.umd.js:755:17)
at AppShellService.prototype.zipContent (ms-appx://9ecba615-ddcd-4c3c-a8f1-a09e9aac3e60/dist/main.js:197:13)"
javascript c# uwp windows-10-universal
javascript c# uwp windows-10-universal
edited Nov 13 at 18:51
asked Nov 12 at 22:44
Houseman
2,66984294
2,66984294
Could you show me that how do you get zippedfolderPathparameter ?
– Nico Zhu - MSFT
Nov 13 at 2:01
As you know, uwp runs in sandbox, you could not pass folder path directly. unless you have addedbroadFileSystemAccesscapability.
– Nico Zhu - MSFT
Nov 13 at 2:19
ok, I will check it.
– Nico Zhu - MSFT
Nov 13 at 2:43
Have you checked this document ?
– Nico Zhu - MSFT
Nov 13 at 2:46
1
Yes, I have tested the code sample, and could reproduce the issue. I have reported this issue to related team.
– Nico Zhu - MSFT
Nov 15 at 2:27
|
show 4 more comments
Could you show me that how do you get zippedfolderPathparameter ?
– Nico Zhu - MSFT
Nov 13 at 2:01
As you know, uwp runs in sandbox, you could not pass folder path directly. unless you have addedbroadFileSystemAccesscapability.
– Nico Zhu - MSFT
Nov 13 at 2:19
ok, I will check it.
– Nico Zhu - MSFT
Nov 13 at 2:43
Have you checked this document ?
– Nico Zhu - MSFT
Nov 13 at 2:46
1
Yes, I have tested the code sample, and could reproduce the issue. I have reported this issue to related team.
– Nico Zhu - MSFT
Nov 15 at 2:27
Could you show me that how do you get zipped
folderPath parameter ?– Nico Zhu - MSFT
Nov 13 at 2:01
Could you show me that how do you get zipped
folderPath parameter ?– Nico Zhu - MSFT
Nov 13 at 2:01
As you know, uwp runs in sandbox, you could not pass folder path directly. unless you have added
broadFileSystemAccess capability.– Nico Zhu - MSFT
Nov 13 at 2:19
As you know, uwp runs in sandbox, you could not pass folder path directly. unless you have added
broadFileSystemAccess capability.– Nico Zhu - MSFT
Nov 13 at 2:19
ok, I will check it.
– Nico Zhu - MSFT
Nov 13 at 2:43
ok, I will check it.
– Nico Zhu - MSFT
Nov 13 at 2:43
Have you checked this document ?
– Nico Zhu - MSFT
Nov 13 at 2:46
Have you checked this document ?
– Nico Zhu - MSFT
Nov 13 at 2:46
1
1
Yes, I have tested the code sample, and could reproduce the issue. I have reported this issue to related team.
– Nico Zhu - MSFT
Nov 15 at 2:27
Yes, I have tested the code sample, and could reproduce the issue. I have reported this issue to related team.
– Nico Zhu - MSFT
Nov 15 at 2:27
|
show 4 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271182%2fwinrterror-unknown-runtime-error-when-referencing-a-c-sharp-component-from-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you show me that how do you get zipped
folderPathparameter ?– Nico Zhu - MSFT
Nov 13 at 2:01
As you know, uwp runs in sandbox, you could not pass folder path directly. unless you have added
broadFileSystemAccesscapability.– Nico Zhu - MSFT
Nov 13 at 2:19
ok, I will check it.
– Nico Zhu - MSFT
Nov 13 at 2:43
Have you checked this document ?
– Nico Zhu - MSFT
Nov 13 at 2:46
1
Yes, I have tested the code sample, and could reproduce the issue. I have reported this issue to related team.
– Nico Zhu - MSFT
Nov 15 at 2:27