问题
Cleaned and rebuilt everything many times, restarted VS and computer but no progress. Patching some bugs in the QueryCommander open source project, I came across an issue where Debug builds, but Release does not. I get this error in Release mode only:
CS0246 The type or namespace name 'AxSHDocVw' could not be found (are you missing a using directive or an assembly reference?)
QueryCommander.Help C:\Workspace\QueryCommander_4_0_0_0\QueryCommander.Help\WinGui\FrmHelpBrowser.cs
The reference does actually exists:
And it does contain the missing namespace:
The unit FrmHelpBrowser.cs
does not have a using
directive indeed, but I am not sure why that works in Debug
mode and what should be used here:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using QueryCommander.Help.WinGui.Base;
namespace QueryCommander.Help.WinGui
{
/// <summary>
/// Summary description for FrmHelpBrowser.
/// </summary>
public class FrmHelpBrowser : FrmBaseContent
{
public AxSHDocVw.AxWebBrowser axWebBrowser1; // Error on this line
//----------------^ here
What is missing in the release mode?
回答1:
Argh! The reference in the original project was to the DLL sitting under bin\Debug
(looking at the reference properties window). I deleted the reference and added it using the AxInterop.SHDocVw.dll
in the solution's root directory - problem solved!
来源:https://stackoverflow.com/questions/44460026/are-you-missing-a-using-directive-or-assembly-reference-am-i-or-am-i-not