I've been working on an IE9 plugin using the .net4 version of SpicIE. On my development machine, everything works great. While testing on a deployment machine, I keep getting a NullReferenceException when attempting HostInstance.BrowserRef.Navigate(URL). I added some logging and it is being reported as null on both machines, but it works without issue on the dev machine. I know at one time it worked on the deployment one and have no idea what might have broken it.
Relevant code follows:
From the plugin base:
public class KB_Toolbar : SpicIE.Host
{
...
public static KB_Toolbar HostInstance;
public KB_Toolbar() : base()
{
HostInstance = this;
}
public static void OpenURL(string URL)
{
if (HostInstance != null)
HostInstance.BrowserRef.Navigate(URL);
}
}
From the toolbar class:
private void MenuClick(object sender, EventArgs e)
{
var URL = vURL[(int)((ToolStripDropDownItem)sender).Tag];
KB_Toolbar.OpenURL(URL);
}
If I leave the HostInstance != null check there, it does not execute the next line on either machine. If I remove it, it executes with no problem on the dev, and throws a NRE on the deployment. I've tried a number of cheap hacks to work around it with no luck. I can't for the life of me figure out what is going on here, especially that it DOES work on the dev machine WHILE supposedly being null.
Any assistance would be greatly appreciated!
Solved it. The answer was a missing /codebase switch in the regasm command.
Related
Following various examples from MS and elsewhere, I have written this piece of test code...
[ComImport]
[Guid("4AEEEC08-7C92-4456-A0D6-1B675C7AC005")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface IInitializeWithWindow
{
void Initialize(IntPtr hwnd);
}
and..
private async Task<bool> TestCode()
{
StoreContext Store = StoreContext.GetDefault();
StoreAppLicense licence = await Store.GetAppLicenseAsync();
bool trial = licence.IsTrial;
bool full = licence.IsActive;
IInitializeWithWindow initWindow = (IInitializeWithWindow)(object)Store;
initWindow.Initialize(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
StoreProductResult App = await Store.GetStoreProductForCurrentAppAsync();
StoreProduct p = App.Product; // Title, price
string title = p.Title;
StorePrice price = p.Price;
return true;
}
And I call it with using
bool x = TestCode().Result;
It all compiles and runs, so I presumably have all the right usings and references added. But when run, the line:
IInitializeWithWindow initWindow = (IInitializeWithWindow)(object)Store;
stops with the exception..
Unable to cast object of type 'Windows.Services.Store.StoreContext'
to type 'IInitializeWithWindow'
and I have no clue why.
This is a C# program with a UWP wrapper creating an MSIX package.
This seems to be a pretty standard block adapted from various examples from MS.
Within VS 2019, I have associated the program with the store app.
The 'trail' and 'full' variables seem to be populating correctly.
I have called this from various locations, Constructor, random button, etc.
My questions...
Why does the cast throw an exception?
Is this an old way of doing things that no longer applies?
Does associating the package in VS 2019 to the store app make the call to IInitalizeWithWindow redundant?
How do I fix the code so that 'title' and 'price' populate correctly?
Heaps of head bashing and I finally have it working...
Considering that in the last few days there was not a combination/permutation that I did not try, I don't know really the logic of it working now, but anyway..
Within the UWP installer project I associated the project with the App in the Microsoft Store, then I removed the lines:
[ComImport]
[Guid("4AEEEC08-7C92-4456-A0D6-1B675C7AC005")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface IInitializeWithWindow
{
void Initialize(IntPtr hwnd);
}
IInitializeWithWindow initWindow = (IInitializeWithWindow)(object)Store;
initWindow.Initialize(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
The rest is now working just fine. Funny as I had already associated the app with the store AND removed the offending lines. I must have done something just a little bit different this time!
GitLab ships a wrong C# code encoding. Maybe someone might know a reason for this and a way to fix this?
I am working on a project for something like 3 months. All that time I worked from the office, so I did not have to deploy the project locally at my home computer, only at the computer on work. There on work I somehow managed to deploy a project successfully, but here at home while deploying and setting everything up I come across errors in the project.
All due to that piece of code:
public static object ParseReferred(this JObject item, JsonSerializer serializer, RetypeEnum retype)
{
if (item == null)
{
return null;
}
if (retype == RetypeEnum.)
{
return serializer.Deserialize(item.CreateReader(), typeof(TypeRegNumber));
}
return serializer.Deserialize(item.CreateReader(), typeof(TypeTaskNumber));
}
Here is how I see that piece in GitLab:
Here is the GitLab raw view:
Raw code:
public static object ParseReferred(this JObject item, JsonSerializer serializer, RetypeEnum retype)
{
if (item == null)
{
return null;
}
if (retype == RetypeEnum.�)
{
return serializer.Deserialize(item.CreateReader(), typeof(TypeRegNumber));
}
return serializer.Deserialize(item.CreateReader(), typeof(TypeTaskNumber));
}
I suspect that the only one who could have helped me with the issue was my team lead. So, I asked him what I could do about it. He suggested the following: clearing NuGet cache, restoring NuGets, cleaning the solution, and then rebuilding the solution. I followed the steps, but with no success. I feel myself very stupid, I must have missed something.
Is it true that the only way to fix the issue is to communicate with someone who has known the codebase for sometime? Or are there other possible ways to research the issue? I am really stuck, I do not know what I can try to research the issue.
When I hover over the symbol here is what I see:
'RetypeEnum' does not contain a definition for 'ä'
When I open the RetypeEnum definition (by Ctrl+click on the RetypeEnum) here is what I see:
#region Assembly foo, Version=2.0.8.0, Culture=neutral, PublicKeyToken=null
// foo.dll
#endregion
using System.CodeDom.Compiler;
namespace foo
{
[GeneratedCode("xsd", "4.6.1055.0")]
public enum RetypeEnum
{
д = 0,
з = 1
}
}
Try to check out code files line endings.
I have just started using Parse.com On Unity 5.0.0fb, and after getting my application to work with Parse on Unity Editor I decided to try it on my Mobile to find nothing works. I have checked the APK and Parse is inside it but when I try anything it does not work.
I have tested this with a Test APK with nothing but parse and the test script attached to a button and it also does not work.
using UnityEngine;
using System.Collections;
using Parse;
public class ScriptTest : MonoBehaviour {
public UnityEngine.UI.Text Mytext;
string mytext;
// Use this for initialization
public void MySpecial () {
ParseObject testObject = new ParseObject("TestObject");
testObject["foo"] = "bar";
testObject.SaveAsync();
mytext = "Saved";
Mytext.text = mytext;
Debug.Log (mytext);
}
// Update is called once per frame
void Update () {
}
}
It will not do anything the button will click it will say saved on my text but when I check parse TestObject nothing will be there. Is there something im missing in my build?
I have made sure stripping is also disabled.
This works 100% in editor just not in Android I have no idea or way to test iOS.
I have the exact same problem, using Unity 5.1 and Parse Unity SDK 1.5.1. It works perfectly in the editor but not on Android.
Here's my code :
ParseObject _localPlayer = new ParseObject();
Task query = _localPlayer.SaveAsync();
while (!query.IsCompleted)
yield return null;
if (!query.IsFaulted && !query.IsCanceled)
{
Debug.Log ("Player successfully created!");
}
else
{
Debug.Log("Failed to create player...");
}
The task generated with the SaveAsync() request doesn't seem to end at all (isCompleted is never true) so it becomes an infinite loop, and the actual cloud operation is not performed (no trace on the Parse dashboard). There doesn't seem to be any exception thrown and the device log doesn't show anything.
I'm really stuck at this point and haven't be able to find any solution anywhere on the web so far. :(
Using Parse SDK 1.3.2 "fixes" the issue.
-> https://parse.com/downloads/windows/Parse/1.3.2
Looks like a big fat regression. ;)
Going back to Parse Unity SDK 1.3.2 worked for me.
LogOutAsync() had to be replaced with LogOut(), but that was the only change I had to make in my code.
The solution to this problem is to reimport project settings from their blank project. It will fix any build problems you have.
The bug report, for those who would like to be kept informed:
https://developers.facebook.com/bugs/1623483557935932/
I wanted to implement a simple activation function to my C# application. It was something like this:
class Activation
{
public Activation()
{
Some code...
}
public void SomeFunction()
{
Some code...
string s = NumberOfDaysToExpire();
}
}
The complete code is not a problem. The class sets some values to the Windows registry. I decided to launch the instance of this class in the main form's constructor and it worked fine.
The problem appeared when I decided to exclude this class from the project. The code shouldn't work but it still works !!! There is no declaration of this class in the whole project - so why does it still work ? I think this is a Visual Studio 2012 problem. Please help me.
Regards,
Mariusz
I migrated Mining Structures from a 2008 server to a 2012 server. When I try my CLR UDF (which is working fine on SQL server 2008) in a DMX query on the 2012 server, I am getting this error:
Exception has been thrown by the target of an invocation. Object reference not set to an instance of an object.
My original goal was to get the GetNodeDescription(...) method running. While debugging the problem, I could isolate the problem to this UDF which fails on my SQL server 2012
[SafeToPrepare(true)]
public static string test()
{
return Context.CurrentMiningModel.Name;
}
My guess is that CurrentMiningModel is null because the following code works fine
[SafeToPrepare(true)]
public static string testUser()
{
return Context.CurrentConnection.User.Name;
}
Any Idea on how to solve this?
Is somebody out there who can reproduce this?
Thanks.
Jan
UPDATE:
A contact at Microsoft confirmed this behaviour as desired due to a "Metadata-Refactoring" (whatever this means...). However, the website still pends to be updated appropiately.
This is not the ultimate answer but it's a workaround to get Microsoft's GetNodeDescription working (by explicitly providing the mining model):
[SafeToPrepare(true)]
public static string GetNodeDescription(string MiningModel, string nodeUniqueName)
{
if (Context.ExecuteForPrepare)
{
return string.Empty;
}
return Context.MiningModels[MiningModel].GetNodeFromUniqueName(nodeUniqueName).Description;
}