Share via

WinInet - won't work in a UWP project with Release mode

Huang, Jiang 41 Reputation points
2022-07-11T07:50:20.947+00:00

In a UWP project, the Wininet is used. It works well in Debug mode.
However, it doesn't work in Release mode.
the error message is "Unresolved P/Invoke method 'wininet.dll!InternetSetOption' from this method. Please look for this method in build warnings for more details. "
InternetSetOption is the method called, if another method is called, the problem still exists.

the demo project link: https://github.com/JokHuang/TestWininet.git

Developer technologies | Universal Windows Platform (UWP)

Answer accepted by question author

Anonymous
2022-07-12T06:13:49.817+00:00

Hello,

Welcome to Microsoft Q&A!

I've checked the code that you shared. The behavior you got is expected. You are using InternetGetCookieA function, InternetSetCookieA function and InternetSetOptionA function in your app. But all these methods as well as their extended method are available only for desktop apps. It means you can't use that in a UWP application. That's why you get exceptions in the release mode.

If you want to use these APIs in your UWP app, what you could do is create a console application and call these APIs from the console application. Then package the console app together with the UWP application via desktop bridge. You could search for UWP with Desktop Extension – Part 1 -stefanwick on the search engine to find a blog. It contains a tutorial about how to implement the desktop bridge.

Thank you.


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.