I am a newbie to visual studio so apologies in advance for anything dumb I ask or say.
I am trying to inject a username and password into a document and automatically sign in to a https web site.
I use the code as follows:
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using System.Windows.Forms;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using TasKey2.Resources;
using System.IO.IsolatedStorage;
namespace myapp
{
public partial class MainPage : PhoneApplicationPage
{
bool isLoggedOn = true;
private string splashScreen = "https://xxxxxxt";
private string teamScreen = "https://xxxxxxx";
private string mainUrl;
private string username, password;
private bool loggedOn;
System.Windows.Forms.WebBrowser webBrowser;
......
private void Browser_Loaded(object sender, RoutedEventArgs e)
{
Browser.IsScriptEnabled = true;
if (isLoggedOn)
{
mainUrl = teamScreen;
Browser.Navigate(new Uri(mainUrl, UriKind.Absolute));
HtmlElement userName = webBrowser.Document.GetElementById("Login1_UserName");
userName.SetAttribute("value", username);
userName.RemoveFocus();
HtmlElement passWord = webBrowser.Document.GetElementById("Login1_Passwrod");
passWord.SetAttribute("value", password);
HtmlElement logonForm = webBrowser.Document.GetElementById("Login1_LoginButton");
logonForm.InvokeMember("click");
}
When I do I get the following error:
Error 1 The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
Error 2 The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
Error 3 The type or namespace name 'NavigateEventHandler' could not be found (are you missing a using directive or an assembly reference?)
SO I go to the Object Browser and can add System.Windows.Forms v2 and v4
Regardless of which one I addd I now get the following error:
Error 2 The base class or interface 'System.ComponentModel.Component' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' referenced by type 'System.Windows.Forms.Control' could not be resolved c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Windows.Forms.dll
I am banging my head against a bring wall on this. How do I add the System.Windows.Forms to my code and make it work?
Related
I need to include a string into a BQL so, I have created a private class within a class to define a constant string that is utilized in the BQL.
The problem that I'm facing is, that this code it is not passing the validation when I publish.
I'm getting the following error:
" \App_RuntimeCode\PX_Objects_SO_AddSOFilter_extensions.cs(48): error CS0246: The type or namespace name 'TypeCS' could not be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\PX_Objects_SO_AddSOFilter_extensions.cs(60): error CS0246: The type or namespace name 'TypeCS' could not be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\PX_Objects_SO_AddSOFilter_extensions.cs(48): error CS0246: The type or namespace name 'TypeCS' could not be found (are you missing a using directive or an assembly reference?)
"
Any help or suggestion will be greatly appreciated.
namespace PX.Objects.SO
{
[PXNonInstantiatedExtension]
public class SO_AddSOFilter_ExistingColumn : PXCacheExtension<PX.Objects.SO.AddSOFilter>
{
private class TypeCS : Constant<string>
{
public TypeCS() : base("CS")
{
}
}
#region OrderType
[PXDBString(2, IsFixed = true, InputMask = ">aa")]
[PXSelector(typeof(Search2<SOOrderType.orderType,
InnerJoin<SOOrderTypeOperation, On<SOOrderTypeOperation.orderType, Equal<SOOrderType.orderType>>>,
Where<SOOrderType.active, Equal<True>,
And<SOOrderType.requireShipping, Equal<True>, Or<SOOrderType.orderType, Equal<TypeCS>,
...
[PXDefault(typeof(Search2<SOOrderType.orderType,
InnerJoin<SOOrderTypeOperation, On<SOOrderTypeOperation.orderType, Equal<SOOrderType.orderType>>,
LeftJoin<SOSetup, On<SOSetup.defaultOrderType, Equal<SOOrderType.orderType>>>>,
Where<SOOrderType.active, Equal<True>,
And<SOOrderType.requireShipping, Equal<True>, Or<SOOrderType.orderType, Equal<TypeCS>,
... [PXUIField(DisplayName = "Order Type")]
[PXFormula(typeof(Default<AddSOFilter.operation>))]
public string OrderType { get; set; }
#endregion
}
}
Make the bql constant public as the framework is not able to see the constant being declared as private.
public class TypeCS : Constant<string>
{
public TypeCS() : base("CS")
{
}
}
I have been trying to create a automapper Custom value resolvers, but I seem to have missed some set up step as it can never seem to find
public abstract class ValueResolver<TSource, TDestination> : IValueResolver
So in the following snippet will not compile.
using DITest.Models; // This is where the SalesOrder class is
using AutoMapper;
namespace DITest.AutoMapper.SaleOrder
{
public class FullAddress : ValueResolver<SalesOrder, string>
{
protected override string ResolveCore(SalesOrder source)
{
return "foo bar";
}
}
}
I get the error message
The type or namespace name 'ValueResolver<,>' could not be found (are you missing a using directive or an assembly reference?)
Its say the using AutoMapper is not used.
In the past I have been naughty and hacked in a reference for lib\net45\AutoMapper.dll
Please try IMemberValueResolver type instead of IValueResolver. The AutoMapper had some upgraded things.
https://github.com/AutoMapper/AutoMapper/wiki/5.0-Upgrade-Guide
ValueResolver is gone. IValueResolver is the replacement. And there is also IMemberValueResolver, as the docs say.
I'm having some trouble with an Helper/Extension class I made. When trying to use it in my razor view I get
Compiler Error CS0234. The type or namespace name 'name' does not exist in the namespace 'namespace' (are you missing an assembly reference?)
I have a MVC 5 web project where I have a class library (which works as an addon) containing my UI controllers and views. The view was rendering and my controller action is executing.
When I do #using my_project.UI.Navigation, I get compiler error CS0234. Later in my view I have a call to #NavigationHelper.BuildHtml() (which full is in my_project.UI.Navigation).
But my controller can execute just fine:
#using my_project.UI.Navigation
namespace my_project.Controllers
{
public UiController : IController
{
public ActionResult Index()
{
var test = NavigationHelper.BuildHtml();
return View();
}
}
}
both classes and namespaces are in the same assembly.
I am developing an extension to VS2013. Since it will be installed through MSI, I am changing the base directory to installation folder using ProvideBindingPath attribute to package class. But the 3rd party dll reference which will be loaded in runtime is not picking dll from the probed path. Its always looking into Visual studio devenv.exe folder. Is there any way to force the dll to look into my installation folder.
using MD=Microsoft.VisualStudio.Modeling.Shell;
MD.ProvideBindingPath(SubPath = #"")]
public sealed class AutomationCommandPanePackage : Package
{
public AutomationCommandPanePackage()
{
string installationPath = HelperMethods.GetInstallationPath();
if (string.IsNullOrEmpty(HelperMethods.GetInstallationPath())) return;
// Change default config file at runtime.
using (AutomationConfigurationManager.Change(installationPath, "AutomationPro.config"))
{
// Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
}
Assembly a = Assembly.GetExecutingAssembly();
Type type = a.GetType("AutomationCommandPanePackage", true);
System.Reflection.MemberInfo info = type;
var attributes = info.GetCustomAttributes(true);
foreach (var attrib in attributes)
{
if (attrib is MD.ProvideBindingPathAttribute)
{
((MD.ProvideBindingPathAttribute)attrib).SubPath = installationPath;
break;
}
}
I have been able to successfully load third party (telerik) assemblies in my extension using below code.
Register to AssemblyResolve event in your Package class constructor
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
Then in handler load packages as below:
string path = Assembly.GetExecutingAssembly().Location;
path = Path.GetDirectoryName(path);
if (args.Name.ToLower().Contains("telerik.windows.controls.gridview"))
{
path = Path.Combine(path, "telerik.windows.controls.gridview.dll");
Assembly ret = Assembly.LoadFrom(path);
return ret;
}
I have not had any issues with the above approach.
I resolved issue using
LoadLibrary() from
System.Runtime.InteropServices;
since my dll to be loaded is a COM iterop dll.
public static class win32
{
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName); [DllImport("kernel32.dll")]
public static extern bool FreeLibrary(IntPtr hModule);
}
in package.cs I loaded assembly like this
win32.LoadLibrary(Path.Combine(installationPath, "apidsp_windows.dll"));
In ServiceStack is there an implementation of HttpError?
I can find the interface definition:
namespace ServiceStack.ServiceHost
{
public interface IHttpError : IHttpResult, IHasOptions
{
string ErrorCode { get; }
string Message { get; }
}
}
But am I missing a using directive, because I get this compiler error:
The type or namespace name 'HttpError' could not be found (are you missing a using directive or an assembly reference?)
The HttpError class is in the ServiceStack.Common.Web namespace (ServiceStack.Common assembly/NuGet package) in the current (version 3) release of ServiceStack.
In under-development version 4, looks like it was moved to the root ServiceStack namespace.
I just found out how to search namespaces, in VS2012 anyway... Select the class and type Shift-Alt-F10... this causes a little dropdown box to appear... click on it and you will see the namespaces that have matching class names!