I am trying to access the My.Computer object in a class library project (Visual Studio CE). I know people say that I should find in Project Properties a "My Extensions" option - but it's just not there.
Microsoft site says the exact same thing but I just can't find that option.
To access the My Extensions page, double-click My Project for your project node in Solution Explorer. When the Project Designer appears, click the My Extensions tab.
https://learn.microsoft.com/en-us/visualstudio/ide/reference/my-extensions-page-project-designer-visual-basic?view=vs-2017
Besides that, Microsoft says the My.Computer should be available in Class Library project. Well, it's not. As a matter of fact My is totally empty.
https://learn.microsoft.com/en-us/dotnet/visual-basic/developing-apps/development-with-my/how-my-depends-on-project-type
LE:
Visual Studio Community 2017 15.8.1
.NET Framework 4.6.01055
Class Library type: .NET Standard
ANSWER: .NET Standard Class Library does not have My extensions. Use .NET Framework Class Library when creating the project to be able to access My objects.
Related
I want to store startup settings for my project. When I go to the project Properties/Settings, it's empty except for a link that says, "This project does not have a default settings file. Click here to create one." When I click the link to add one, it says "The system cannot find the file specified. (Exception from HRESULT: 0x80070002." So, how do I add a default settings file?
As mentioned in my comments, this seems to be a bug in VS and ought to be reported to Microsoft. As a temporary workaround, you can actually copy the settings files from a .NET Framework project into a .NET Core project. As far as I can tell from examining various VB and C# projects targeting .NET Framework and .NET Core, the settings files are the same in each case, so there's no issue copying between them. Here's what I did:
Added a VB WinForms app project targeting .NET Framework to the same solution.
Clicked the Show All Files button in the Solution Explorer for both projects.
Expanded the My Project node for both projects.
Dragged the Settings.settings item from the .NET Framework project to the .NET Core project.
It seemed to work as expected after that.
When creating a .Net Standard (Visual Basic) project in Visual Studio, the properties window presents no "Signing" tab. This is not an issue with .Net Standard (C#) projects, nor Visual Basic projects which are not .Net Standard.
Why this specific configuration, and is there any way to circumvent it?
In the end, I never found a way of automatically signing an assembly through Visual Studio's interface for this specific project template. However, I did find a workaround using custom build steps.
Visual Studio's interface also didn't allow this either, for whatever reason, so I had to manually edit the .vbproj file. Here's what it looked like in the end:
<PropertyGroup>
<PostBuildEvent>"Path\To\ildasm" /all /out=Project.il Project.dll</PostBuildEvent>
<PostBuildEvent>del Project.dll</PostBuildEvent>
<PostBuildEvent>"Path\To\ilasm" /dll /key="Path\To\Key.snk" Project.il</PostBuildEvent>
</PropertyGroup>
As you can see, all we're doing is disassembling the dll into an intermediate language file, and then reassembling it with a strong name
For the sake of simplicity (... and laziness), using project environment variables is left as an exercise to the reader :^).
Here's the situation:
We have classic ASP running for our site.
We have VB6 DLLs, running inside the ASP as COM Objects.
I have moved over to Visual Studio 2008. I am trying to create DLLs that I can utilise in ASP the same way we would with VB6 (Server.CreateObject("")). Unfortunately, although registering is successful, I get a:
"The call to Server.CreateObject failed while checking permissions. Access is denied to this object." Error.
I have done plenty of research and found that you must register the VB.NET DLL with 'regasm' (which I did) you also need to tick the appropriate ("Make assembly COM-Visible") box.
However, through all my efforts, it seems I have run out of luck.
I did read something about having a class template called "COM Class" in order to create COM DLLs in VB.NET, but I do not have that option in the template choice.
So my question is, do I change to visual studio (non-express to obtain the COM class template and if so, would that definitely work?)
OR
Is there something that I am not doing correctly?
Please note moving to ASP.NET is not an option, nor programming in VB6.
Thanks!
EDIT
After about a full week of searching, I have found the answer, for anyone who finds this page: http://social.msdn.microsoft.com/Forums/en-US/9f84bdf7-aace-4a57-a3e4-3863a0efb647/how-to-create-comvisible-dll-that-i-can-use-from-vba-using-vs-express-2008-beta-2
man you have to read about .net a lot.
you cannot just write a .net dll and then use this in classic asp. These are two completely different Technologies.
it has absolutely nothing to do with visual Studio. Visual Studio is just the development Environment and has absolutely nothing to do with your .net Framework or your web application. you cannot use visual Studio > version 6 for vb6 programming. so you cannot create vb6 dlls with visual Studio 2008n or 2010 or 2003 or 2005.
you can write .net dlls and use them in classic asp or any other com Aware Technology. but they are still .net dlls which require the .net Framework. they are just com visible.
that is a bit complicated but possible:
you classes and methods have to be "com visible" you achieve this by using the Attribute [ComVisibleAttribute( true )]
just before the declaration of your class and before every method you want to be com visible.
example:
[ComVisibleAttribute( true )]
public class Helper {
public Helper() {
}
[ComVisibleAttribute( true )]
public object parseDate( string strDate ) {
return (object)DateTime.Parse( strDate ).ToString( "dd.MM.yyyy HH:mm:ss" );
}
}
you have to use an emtpy constructor for your classes!
furthermore you have to check "Assemlby Com visible" in Project properties-> assemblyinformation
or open Properties/AssemblyInfo.cs and add These lines:
[assembly: ComVisible( true )]
[assembly: Guid( "e2e1670d-1f90-4948-98be-27cc820b4675" )]
after you have build your dll you then have to use the ragasm.exe to Register the .net dll in the registry. (normal .net dlls are note registeres n the registry by default.
you can do that like so:
%windir%\Microsoft.NET\Framework\v4.0.30319\regasm.exe path/and/Name/of/your.dll /codebase
you have to make sure that the path to your wanted .net Framework is correct.
after that you have to restart your iis and can then use the .net dll methids from classic asp.
please be Aware that you can only pass and return values of simple datatypes to your .net methods from/to clasic asp like string, int etc.
Answer:
http://social.msdn.microsoft.com/Forums/en-US/9f84bdf7-aace-4a57-a3e4-3863a0efb647/how-to-create-comvisible-dll-that-i-can-use-from-vba-using-vs-express-2008-beta-2
Built the .dll, and targeted .NET Framework 3.5, making it COM visible.
Used the GAC utility that was installed with the Visual Studio 2008 Beta 2 (and hence >.NET Framework 3.5) - it was in C:\Program FIles\Microsoft SDKs\Windows\V.0A\bin - to place .the generated .dll into the GAC
Used the regsam.exe file I found in c:\ Windows\Microsoft.NET\framework\V2.0.50727 to >register the generated .dll.
Used the tlbexp.exe file I found in C:\Program FIles\Microsoft SDKs\Windows\V.0A\bin to >.export a .tlb file
In the VBA IDE, used Tools->References to browse to the .tlb file and select it as an >addtional reference.
The problem was that i was not doing step 2 or step 4.
I hope this helps someone in the future as it took me very long to solve.
I developing C#\XAML metro-ui application. I need some .NET types that doesn't included in .NET for Metro style apps or Windows references (for instance HttpUtility that is located in System.Web). I can't find System.Web via Assembly List. In same time I can refer it via Browse. But as I understand correct isn't it good way and I should avoid this, is it?
Next thing I have found description of Assembly Class. In the bottom of page in Version Information section I can see that it is supported by Portable Class Library. In the sample I see next code
Assembly assem = Assembly.GetExecutingAssembly();
But in my project Assembly doesn't have GetExecutingAssembly method. Is it documentation outdated? or I miss something?
I use Windows 8 Release Candidate and VS 2012
EDIT0: Instead of HttpUtility I should use WebUtility I know it. But I choose this type just for example.
EDIT1: I see public static System.Reflection.Assembly GetExecutingAssembly() via Object Browser but can't reach it.
Metro style apps can only call methods in the .NET Core Profile. You can see the Core Profile reference assemblies on Windows 8 RP machine at ...
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5
You can use ILDasm or ILSpy to view them. See A .NET developer's view of Windows 8 app development video from Build. He talks more about the Core Profile and why some classes, methods and interfaces were removed.
I have a C++ DLL project which is created in VS 2010. It is exposed as COM(ATL). I used this dll to another .NET Project as reference. C++ Project linker settings are set as follows:
"Register Output" = Yes
"Per-user Redirection = Yes
I created a build definition to build these two projects in tfs 2010. C++ Project builds fine, but .NET project fails because the output dll of C++ project is not registered. Setting to "Per-User redirection" = false does not work. I also tried using WF activity 'InvokeProecss' to register the c++ dll using Regsrv32/batch file/my own exe etc, but I get exit code of 5. My TFS 2010 is in Windows 2008 Server R2. And I think, it's not running the process as admin.
If I generate a interop dll using tlbimp, and then I refer that interop in my .NET proejct, it works fine(oviously in tfs build, I need to add InvokeProecss to call tlb). But this is not acceptable as our general practice is to refer a COM dll directly from .NET proejct.
Can anybody please help about this?
Is there a way to run the tfs automated build activity 'InvokeProcess' as Administrator without prompting for user name/password?
By default, the TFS Build Service runs as the "Network Service" account which is a relatively low-privilege account. Alternatively, you can configure it to run as any domain account you like. I wouldn't recommend that as a solution to the problem you described, however. I would agree with Hans that, in this case, it would be better to use the type library importer (TlbImp.exe) to "reference" your COM server from your managed assembly.
If the COM object isn't changing, you can just use the type library importer to generate an interop assembly, check that in and reference it from your .NET project. If it is changing, you can add a post-build step to generate the interop assembly rather than using the InvokeProcess activity. As Hans pointed out, you can't actually reference a COM object directly from a managed assembly. Your reference is actually causing an interop assembly to get generated at build time after resolving the reference to the registered COM server.