WinRTError: Unknown runtime error when referencing a c# component from javascript










3














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:



enter image description here



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)"









share|improve this question























  • Could you show me that how do you get zipped folderPath parameter ?
    – Nico Zhu - MSFT
    Nov 13 '18 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 '18 at 2:19










  • ok, I will check it.
    – Nico Zhu - MSFT
    Nov 13 '18 at 2:43










  • Have you checked this document ?
    – Nico Zhu - MSFT
    Nov 13 '18 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 '18 at 2:27















3














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:



enter image description here



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)"









share|improve this question























  • Could you show me that how do you get zipped folderPath parameter ?
    – Nico Zhu - MSFT
    Nov 13 '18 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 '18 at 2:19










  • ok, I will check it.
    – Nico Zhu - MSFT
    Nov 13 '18 at 2:43










  • Have you checked this document ?
    – Nico Zhu - MSFT
    Nov 13 '18 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 '18 at 2:27













3












3








3







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:



enter image description here



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)"









share|improve this question















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:



enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 18:51







Houseman

















asked Nov 12 '18 at 22:44









HousemanHouseman

2,73484494




2,73484494











  • Could you show me that how do you get zipped folderPath parameter ?
    – Nico Zhu - MSFT
    Nov 13 '18 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 '18 at 2:19










  • ok, I will check it.
    – Nico Zhu - MSFT
    Nov 13 '18 at 2:43










  • Have you checked this document ?
    – Nico Zhu - MSFT
    Nov 13 '18 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 '18 at 2:27
















  • Could you show me that how do you get zipped folderPath parameter ?
    – Nico Zhu - MSFT
    Nov 13 '18 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 '18 at 2:19










  • ok, I will check it.
    – Nico Zhu - MSFT
    Nov 13 '18 at 2:43










  • Have you checked this document ?
    – Nico Zhu - MSFT
    Nov 13 '18 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 '18 at 2:27















Could you show me that how do you get zipped folderPath parameter ?
– Nico Zhu - MSFT
Nov 13 '18 at 2:01




Could you show me that how do you get zipped folderPath parameter ?
– Nico Zhu - MSFT
Nov 13 '18 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 '18 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 '18 at 2:19












ok, I will check it.
– Nico Zhu - MSFT
Nov 13 '18 at 2:43




ok, I will check it.
– Nico Zhu - MSFT
Nov 13 '18 at 2:43












Have you checked this document ?
– Nico Zhu - MSFT
Nov 13 '18 at 2:46




Have you checked this document ?
– Nico Zhu - MSFT
Nov 13 '18 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 '18 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 '18 at 2:27












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















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

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto