I have created a WebPart. When I add the WebPart to a page I get the error below.
If I delete what is in my constructor for my WebPart it will then add to the page. Then if I deploy my code with the WebPart all ready on a page the WebPart will display correctly. I can't add it to other pages I get the error before.
So I presume that there is a problem with the constructor. The line that is breaking it is
var site = new SPSite("http://website/site");
This has been found by commenting code out. Can you not create an SPSite when installing a WebPart?