Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7800863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:46:24+00:00 2026-06-02T00:46:24+00:00

Take the following simple example: interface IVehicle { } class Car : IVehicle {

  • 0

Take the following simple example:

interface IVehicle {
}

class Car : IVehicle {
}

Now I should be able to do the following:

IVehicle vehicle = new Car();

And indeed if I create these base classes as above, I receive no compilation errors (and the code runs.)

But in my project wherever I’m doing something essentially like that (as far as I can see) I get the following error:

Cannot implicitly convert type 'Namespace.Path.Car' to 'IVehicle'. An explicit conversion exists (are you missing a cast?)

Sometimes (as in different code locations, not different compiles) the explicit cast works and sometimes it compiles but creates a runtime exception (invalid cast). Why does the basic example work without issue, and a more detailed class (but still a single class that directly implements the interface) has all these issues?

In some situations, it’ll actually come up with this compile-time error:

Cannot implicitly convert type 'Namespace.Path.IVehicle' to 'IVehicle'. An explicit conversion exists (are you missing a cast?)

I think I’m missing some important condition that is required for this implicit cast to work, but I have not found what difference causes the simple example to work and the more detailed class to fail so strangely. The only thing I’ve seen of note is that the compile time error only includes the namespace on the first type (as shown in the above two errors), but I can’t remember if that is normal or not.

To remove any environmental causes, I created a test case with just the following code:

ISimpleInterface simple = new SimpleImplementation();
IComplexInterface complex = new ComplexImplementation();

The above causes a compile time error on the second line (indicating it cannot do the implicit conversion).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:46:26+00:00Added an answer on June 2, 2026 at 12:46 am

    Found out what’s causing it. This interface is being used as the WCF service contract. Svcutil is apparently creating a duplicate of the interface in the global namespace. Since they were in different namespaces, there was no compilation error. The part about the error indicating two different names (one with the namespace, one without) was an indicator that this was causing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take the following simple object model for example: class Course has_many :enrollments has_many :students,
Take the following example, I have a class public class SomeItem { public string
Take the following example plugin: (function($) { $.fn.alertOnClick = function(text) { return this.each(function(){ $(this).click(alert(text));
Take the following linq query: var summary = results.Select(r => new { TotalPopulation =
Take the following article for example: http://weblogs.asp.net/psteele/archive/2009/11/23/use-dependency-injection-to-simplify-application-settings.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+dotnetmvp+%28Patrick+Steele%27s+.NET+Blog%29 I don't see what benefit there is
For example I have interface ICommand {} class MovePiece : ICommand {} class Successful<CMD>
I have a java threads related question. To take a very simple example, lets
Take the following example. There's an object I want to use, call it a
I'm following a simple example of how to use the update panel from here
Take the following example (created purely to demonstrate the point). What I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.