I am having a really wired issue where I have created a new ASP.Net 4.6 web application (Visual Studio 2015 Community Edition) and everything works fine.
The app will compile without any issues at all but as soon as I try to run the app on the development machine (Windows 10 Enterprise) I get the following error every time and I cannot figure out why?
BC30002: Type 'ConnectionOptions' is not defined.
The code I am using is as follows:
Dim Options As New ConnectionOptions()
Options.Username = HttpContext.Current.Application("WMIUser")
Options.Password = HttpContext.Current.Application("WMIPsssword")
Dim scope As New ManagementScope("\\" & server_name & "\root\cimv2", Options)
scope.Connect()
Dim objectQuery As New ObjectQuery("SELECT FreeSpace FROM Win32_LogicalDisk where DeviceID=""" + deviceId + ":""")
Dim objectSearcher As New ManagementObjectSearcher(scope, objectQuery)
Dim objectCollection As ManagementObjectCollection = objectSearcher.[Get]()
For Each m As ManagementObject In objectCollection
Dim FreeSpace As Double = Convert.ToDouble(m("FreeSpace"))
Next
I have a reference to the System.Management DLL in the references for the application and I have an Imports declaration for it also.
Has anyone come across this before? My searching all leads back to the DLL not being referenced in the application but I have added and removed and re-added without any change.
Please help this is driving me nuts :-(
OK so this is a funny one, posting up just in case someone else comes across the issue.
The way I resolved this problem on the development machine was under References for the project, you have the option to copy local, set this to true and rebuilt the application, ran it and hey presto it all worked.
I can only assume that this could be a permissions thing but this works for the moment anyway.
Hope this helps someone in the future.
Related
We have a VB windows application project using Cefsharp to display browser screen to display some data.
As part of Angular upgrade we have migrated our current cefsharp version from 75.1.142 to 98.1.21.
Reason for not updating to latest cefsharp version is when we did the update the application layout is completely affected, font size reduced, controls broken. So we forced to use lower versions.
We used nuget package manager to update the current version.
It is working fine in our local machine, but after deploying the changes to deployment machine we are getting this
Cefsharp.BrowserSubprocess has stopped working
A problem caused the program to stop working...
Please Note: when we compare the .csproj after the update to 98.1.21 we can see that Cefsharp.Winform is now missing in our latest changes under the imported project lists
Please Note: currently we are using cefsharp in our 2 projects and Target Framework used of these 2 projects are 4.6.2
This is what we have in our CefSettings initialization method
Dim settings As CefSettings = New CefSettings()
settings.remotedebuggingport = findafreetcpport()
settings.cefcommandlineargs.add("disable-gpu", "1")
settings.logfile = ceflogfilename
settings.logseverity = logsiviertity.error
cefsharp.cef.initialize(settings)
And my ChromiumBrowser is initialized like this
_chromeBrowser = new ChromiumWebBrowser(url)
_chromeBrowser.JavascriptObjectRepository.Settings.LedgacyBindingEnabled = True
_chromeBrowser.JavascriptObjectRepository.register("bond", new ChromiumWebBrowserEventHandler(Me),True,BindingOptions.DefaultBinder)
Please note: i haven't provided any BrowserSubProcesssPath during my cefsettings
And in my both .csproj files I have this
<cefsharpanycpusupport>true</cefsharpanycpusupport>
please let me know if you need to know how is my .csproj is configured with cefsharp dll paths.
we also tried different versions but same error is popping out
Any idea why i am facing this problem
Finally after many days of nail biting I managed to solve this problem by doing this steps..
Updated Cefsharp version with Cefsharp 107.1.121 (latest version was affecting our current windows application layouts. So we forced to stick with this version)
Moved LedgacyBindingEnabled = True from my cefsettings to ChromiumWebBrowser initialization section like below
_chromeBrowser = new ChromiumWebBrowser(url)
_chromeBrowser.JavascriptObjectRepository.Settings.LedgacyBindingEnabled = True
_chromeBrowser.JavascriptObjectRepository.register("bond", new
ChromiumWebBrowserEventHandler(Me),True,BindingOptions.DefaultBinder)
Modified cefsettings section by removing the LedgacyBindingEnabled = True code
Then set this broswersubprocess path to absolute (Important) one like this
Dim assemblyPath = System.IO.Path.GetDirectoryName(System.reflection.assembly.GetExecutingAssembly.Location)
If assemblyPath.EndsWith("\") == False Then
assemblyPath = assemblyPath & "\"
End If
Settings.BrowserSubProcesssPath = assemblyPath &
"Cefsharp.BrowserSubprocess.exe"
Hope it helps to someone who updates ur Angular version and stuck because of CefSharp version change.
Spent several hours today trying to write some unit tests against an ASP.NET project. It's Visual Studio 2010.
Using Windows 7 Enterprise with IIS7.
Steps I took were:
Added a new test project to the solution
Opened a class file as part of the web site (Member.vb)
Right clicked within the class file and "Generate unit tests"
Select the methods I wish to generate stubs for, choose to add to my test project, click OK
Open up the generated MemberTest.vb file in the test project, click within one of the generated tests, click "Run tests in curent context"
When following these precise steps on my Windows XP Professional with IIS6 machine it works fine.
However on the Windows 7 Enterprise machine on IIS7 I get:
The URL specified ('http://localhost/MyProject') does not
correspond to a valid directory. Tests configured to run in ASP.NET in
IIS require a valid directory to exist for the URL. The URL may be
invalid or may not point to a valid Web application.
So what's going on, I can confirm I can browse to http://localhost/MyProject and it displays perfectly.
I feel sure I'm missing some sort of config in Windows/IIS but I'm really at a loss.
Generated test method:
<TestMethod(), _
HostType("ASP.NET"), _
UrlToTest("http://localhost/MyProject")> _
Public Sub MyMethodTest()
Dim target As Member_Accessor = New Member_Accessor() ' TODO: Initialize to an appropriate value
Dim CurrentVal As Short = 0 ' TODO: Initialize to an appropriate value
Dim expected As Short = 0 ' TODO: Initialize to an appropriate value
Dim actual As Short
actual = target.MyMethod(CurrentVal)
Assert.AreEqual(expected, actual)
Assert.Inconclusive("Verify the correctness of this test method.")
End Sub
(Cross-posted at ASP.NET Forums)
This could be a permissions issue.
If you're using the default directory (C:\users\\Documents\Visual Studio 2010\Projects), the app identity pool does not have permissions there. You'd have to create a project in something like C:\webs and make sure app pool identity has permission to the folder.
Refer to Rick Anderson's blog post at http://blogs.msdn.com/b/rickandy/archive/2011/04/22/test-you-asp-net-mvc-or-webforms-application-on-iis-7-in-30-seconds.aspx and see if that helps.
If you have not done unit testing before, I would really recommend that you start by just testing the functionality of your classes as cleanly as possible. Try to break you you functionality into small pieces that can be tested individually without and dependencies to the web context.
Have a look at this question for an idea about What is unit testing
Here is an MSDN Magazine article about testing
You can also have a look at this Blog. The examples are using NUnit but the principal is the same if you are using MSTest.
I can also recommend Roy Osheroves Book Art of unit testing
In you case if the Member class does not have dependencies to web context you don't need the IIS and could instead just do something like this:
<TestMethod()> _
Public Sub MyMethodTest()
Dim target = New Member()
Dim CurrentVal As Short = 0 ' TODO: Initialize to an appropriate value
Dim expected As Short = 0 ' TODO: Initialize to an appropriate value
Dim actual As Short
actual = member.MyMethod(CurrentVal)
Assert.AreEqual(expected, actual)
End Sub
I ran into the same problem today. After some research, I found this thread which suggested I check my event log. Upon doing that, I discovered numerous errors similar to the following:
(QTAgent32.exe, PID 12348, Thread 61) WebSites.GetWebServer: failed to
create AspNetHelper:
Microsoft.VisualStudio.Enterprise.Common.AspNetHelperException: The
website metabase contains unexpected information or you do not have
permission to access the metabase. You must be a member of the
Administrators group on the local computer to access the IIS metabase.
Therefore, you cannot create or open a local IIS Web site. If you
have Read, Write, and Modify Permissions for the folder where the
files are located, you can create a file system web site that points
to the folder in order to proceed. --->
System.Runtime.InteropServices.COMException: Unknown error
(0x80005000)
That lead me to this blog post which seems to have resolved the issue.
I just needed to go to "Turn Windows features on or off" and add IIS 6 Management Compatibility and all four subcomponents. I'm running Windows 7 Home Premium which doesn't have the Windows Authentication option, but that didn't seem to be an issue. Give it a shot and see if that resolves the issue for you.
You may need to enable "Use IIS" in the project properties, then click "Create Virtual Directory". Do you have IIS Express installed?
I'm trying to figure out how to use the Microsoft Online Services Migration Toolkit PowerShell Commands from within an ASP.NET website (using vb.NET).
I've started off using a guide on how to use PowerShell in ASP.NET - from here: http://devinfra-us.blogspot.com/2011/02/using-powershell-20-from-aspnet-part-1.html
I'm trying to work out how to implement the Online Services Migration Toolkit PowerShell cmdlets.
Here is a snippet from my code-behind:
Sub GetUsers()
Dim iss As InitialSessionState = InitialSessionState.CreateDefault()
iss.ImportPSModule(New String() {"MSOnline"})
Using myRunSpace As Runspace = RunspaceFactory.CreateRunspace(iss)
myRunSpace.Open()
' Execute the Get-CsTrustedApplication cmdlet.
Using powershell As System.Management.Automation.PowerShell = System.Management.Automation.PowerShell.Create()
powershell.Runspace = myRunSpace
Dim connect As New Command("Get-MSOnlineUser -Enabled")
Dim secureString As New System.Security.SecureString()
Dim myPassword As String = "ThePassword"
For Each c As Char In myPassword
secureString.AppendChar(c)
Next
connect.Parameters.Add("Credential", New PSCredential("admin#thedomain.apac.microsoftonline.com", secureString))
powershell.Commands.AddCommand(connect)
Dim results As Collection(Of PSObject) = Nothing
Dim errors As Collection(Of ErrorRecord) = Nothing
results = powershell.Invoke()
errors = powershell.Streams.[Error].ReadAll()
For Each obj As PSObject In results
Response.Write(obj.Properties("Identity").Value.ToString())
Next
End Using
End Using
End Sub
When I try to run the code via the page, I'm getting the following error
The term 'Get-MSOnlineUser -Enabled' is not recognized as the name of
a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path
is correct and try again.
So I'm guessing I haven't worked out how to import the Online Services Migration Toolkit PowerShell CmdLets. I'm also not exactly sure if the line:
iss.ImportPSModule(New String() {"MSOnline"})
Is exactly correct. Is there a way I can verify the Module name?
I'm also unsure of where and how to reference the .dll files. At the moment I have copied them to my bin folder but I can't add them as references, so how does the ImportPSModule statement know where to find them? Especially when the website is published to the final production server.
One other question, should I be using the x86 or x64 cmdlets? I'm developing on Win7 x64, but not sure if the website builds as x86 or x64? Do I need to find out what architecture the server is?
"Get-MSOnlineUser -Enabled" is not a command; "Get-MSOnlineUser" is. I'm a bit confused how you got it correct further down the script with connect.Parameters.Add("Credential", ...) but didn't do the same thing for -Enabled.
Use connect.AddArgument("Enabled") or connect.Parameters.Add("Enabled", true) and you should be good to go.
Hi was wondering if anyone had come accross this problem before in where a web service was defined yesterday come to try today and its no longer defined.
Ive updated the web-reference folder no errors. The strange thing is when I type in the reference as in
DIM ws AS NEW service.serviseasmx()
What normally happens if VS would pick up on the service in the drop down could I have messed up my web.config file if so is it fixable or any other suggestions?
Thanks
I am debugging this Active X dll using the VB6 IDE. I can see the execution get as far as an attempt to GetObjectContext. This method always returns NOTHING.
This is happening on Windows 7 32 bit, IIS 7. (The application is working in other locations, one of which is Windows Server 2008 with IIS 7)
I have Googled extensively and found many references to this relating to COM+, but there is NO COM+ involved in my scenario. Just plain old Server.CreateObject from a registered dll.
I have ASP code as follows
SET objCalendar = Server.CreateObject("SSYSDEV.Calendar")
objCalendar.BuildCalendar("ADMINUSERS")
SET objCalendar = Nothing
The problem lines of the requested function in the dll are:
Dim objHttpRequest As ASPTypeLibrary.Request
Set objHttpRequest = GetObjectContext.Item("Request")
Any help or suggestions, as always, will be greatly appreciated.
I'm still getting over the shock of having to work with VB6 - I never thought it would happen! It's like being dragged back to the dark ages, in a very rough fashion that's causing blisters!
P.S. I have also set up a COM+ component and had the ASP get the object that way, GetObjectContext returns an empty object in this case, which has no ASP objects in it. So this is no help :-(
I know this is a little late, but I had a similar problem and this solved it for me:
Thread: Problem accessing Request object via COM+
http://forums.iis.net/t/1146404.aspx
Summary: turn on 'Allow IIS Intrinsic Properties' in the COM+ component.
I've found that the COM+ approach to using VB6 components in IIS to be a bit flaky. I add this to a VB6 class that I want to instance in ASP::-
Private moScriptCtx As ScriptingContext
Public Sub OnStartPage(SC As ScriptingContext)
Set moScriptCtx = SC
End Sub
You can now access Request,Response,Server etc as properties of the moScriptCtx object.
You might be wondering how you call OnStartPage in the first place. You don't ASP automagically does that for you during the CreateObject execution.