Open robinwassen opened 11 years ago
Robert Austen contacted me with a solution to the problem.
The core issue that a binary compiled with x86 architecture won't be able to call WlanSetProfileEapXmlUserData on a x64 Windows 7/8. See: http://social.msdn.microsoft.com/Forums/en-US/130b1fef-213b-493b-9aab-0ee8978106b2/wlanapidll-wlansetprofileeapxmluserdata
Mail from Robert
Well after much work, I finally got this working. I haven't been able to convert this to C# yet but I got it working with C++. The key was the make the application x64 in order for it to work with Windows 7 64-bit. So don't forget to change the Active Platform to x64. At least I know this will work on Windows 7 64-bit now. So I was able to use the Native WIFI API in C# to create the profile and then this test C++ application to set the credentials. I verified that it works and I can connect. I probably won't spend too much time trying to get this to work in C#. I might end up just making this into 2 DLLs (x86 and x64) that my C# application will call.
Sample code provided by Robert: https://gist.github.com/robinwassen/6164456
The solution I would propose for SimpleWifi is probably something similar. Create a shim in c++ compiled to both a x86 and x64 assembly, then make the C# library select the appropriate assembly depending on the current OS architecture.
Some followup from Robert:
What is strange is that I created a x64 DLL which sets the XML. In fact I am not passing it any data and is basically my console application turned into a DLL. If my C# calls the DLL, I get the same 1206 error that I was getting before. I have my C# application x64 as well so it appears something funny is going on when a x64 C# console application tries to load a x64 DLL that makes this API call. Worst case scenario I will just make it a console application where you pass it parameters to use.
Looks like the issue is running the application in debug mode within Visual Studio. If I just run the application outside VS it gets a return code of 0.
So doing some more testing. I finally got the PInvoke in C# to work now. The key is that I can't debug in Windows as I have to run the code outside of the application and I have to set the platform to x64. Setting it to Any CPU causes it to fail. So now I don't have to create a C++ DLL.
Thanks for your answer. I shall pass from time to time to see if there has been some progress.
The library does not currently support WPA2 Enterprise.