简体   繁体   中英

How can I put a 64-bit user control into Visual Studio 2012's toolbox?

My Visual Studio 2012 project may end up being memory-intensive, so I have built all of the projects in its solution for a 64-bit processor. There was at least one project (unfortunately I don't remember which) that was left at "Any CPU". I decided to convert the contents of a form to a user control. It built successfully, and I was able to add the resulting DLL to the toolbox and then drag the new control onto a form.

However, I was getting ugly warnings about mismatches between processor selections. To clean them up, I changed all projects to target 64-bit processors. Suddenly, I could not use my 64-bit control on my forms. Research revealed one article that said that Visual Studio is a 32-bit process, and therefore it could not host 64-bit controls in the toolbox, but it is still possible to use those controls dynamically. But the KB article I found dated back to the days of VS 2008.

Is this still true in VS 2012? How can I get my 64-bit control into the toolbox so I can drag and drop it onto a form?

Thank you very much.

Solution: Add a Class Library to your Solution - Use the Any CPU flag to compile. Move your UserControls to this library. Add a reference in your x64 project to this library. Build the solution, and then the UserControls are available in your x64 designers.

I ran into this when writing an application using 64-bit Oracle.DataAccess. The solution then had to become 64-bit, leading to the usual problem with 64-bit controls not being draggable from the Toolbox onto forms. I ended up making all components that had a Designer build with AnyCPU, but the rest of the application as x64. Worked perfectly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM